summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/sdlinput.cpp16
-rw-r--r--src/gui/widgets/tabs/chat/battletab.cpp2
-rw-r--r--src/gui/widgets/tabs/chat/chattab.cpp3
-rw-r--r--src/gui/widgets/tabs/setup_joystick.cpp82
-rw-r--r--src/gui/widgets/tabs/setup_joystick.h6
-rw-r--r--src/gui/windows/chatwindow.cpp4
-rw-r--r--src/gui/windows/quitdialog.cpp5
7 files changed, 72 insertions, 46 deletions
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 9b8b1ec6a..8f3ca8bff 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -171,6 +171,22 @@ void SDLInput::pushInput(const SDL_Event &event)
break;
}
+ case SDL_JOYBUTTONDOWN:
+ case SDL_JOYHATMOTION:
+ case SDL_JOYAXISMOTION:
+ {
+ const InputActionT actionId = inputManager.getActionByKey(event);
+ if (actionId > InputAction::NO_VALUE)
+ {
+ keyInput.setActionId(actionId);
+ keyInput.setType(KeyEventType::PRESSED);
+ mKeyInputQueue.push(keyInput);
+ keyInput.setType(KeyEventType::RELEASED);
+ mKeyInputQueue.push(keyInput);
+ }
+ break;
+ }
+
#ifdef USE_SDL2
case SDL_TEXTINPUT:
keyInput.setType(KeyEventType::PRESSED);
diff --git a/src/gui/widgets/tabs/chat/battletab.cpp b/src/gui/widgets/tabs/chat/battletab.cpp
index 5dd5ff987..9fa18e945 100644
--- a/src/gui/widgets/tabs/chat/battletab.cpp
+++ b/src/gui/widgets/tabs/chat/battletab.cpp
@@ -36,8 +36,6 @@ BattleTab::BattleTab(const Widget2 *const widget) :
ChatTab(widget, _("Battle"), "", "#Battle", ChatTabType::BATTLE)
{
setTabColors(ThemeColorId::BATTLE_CHAT_TAB);
- if (config.getBoolValue("showChatHistory"))
- loadFromLogFile("#Battle");
}
BattleTab::~BattleTab()
diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp
index ec9042694..9809287d2 100644
--- a/src/gui/widgets/tabs/chat/chattab.cpp
+++ b/src/gui/widgets/tabs/chat/chattab.cpp
@@ -97,6 +97,9 @@ ChatTab::ChatTab(const Widget2 *const widget,
if (chatWindow != nullptr)
chatWindow->addTab(this);
mTextOutput->updateSize(true);
+
+ if (config.getBoolValue("showChatHistory"))
+ loadFromLogFile(logName);
}
ChatTab::~ChatTab()
diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp
index ab623b901..297f5bafc 100644
--- a/src/gui/widgets/tabs/setup_joystick.cpp
+++ b/src/gui/widgets/tabs/setup_joystick.cpp
@@ -35,6 +35,7 @@
#include "gui/widgets/dropdown.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/slider.h"
#include "utils/delete2.h"
#include "utils/gettext.h"
@@ -43,12 +44,6 @@
Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
SetupTab(widget),
- mCalibrateLabel(new Label(this,
- // TRANSLATORS: joystick settings tab label
- _("Press the button to start calibration"))),
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton(new Button(this, _("Calibrate"), "calibrate",
- BUTTON_SKIN, this)),
// TRANSLATORS: joystick settings tab button
mDetectButton(new Button(this, _("Detect joysticks"), "detect",
BUTTON_SKIN, this)),
@@ -58,6 +53,13 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
mNamesModel(new NamesModel),
mNamesDropDown(new DropDown(this, mNamesModel,
false, Modal_false, nullptr, std::string())),
+ mToleranceLabel(new Label(this)),
+ mToleranceSlider(new Slider(this, 0.01, 1, 0.01)),
+ mUseHatForMovementCheckBox(new CheckBox(this,
+ // TRANSLATORS: joystick settings tab checkbox
+ _("Use joystick hat (d-pad) for movement"),
+ config.getBoolValue("useHatForMovement"),
+ nullptr, std::string())),
mUseInactiveCheckBox(new CheckBox(this,
// TRANSLATORS: joystick settings tab checkbox
_("Use joystick if client window inactive"),
@@ -73,10 +75,19 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
mJoystickEnabled->setActionEventId("joystick");
mJoystickEnabled->addActionListener(this);
- mCalibrateButton->setEnabled(mOriginalJoystickEnabled);
+
+ const float tolerance = config.getFloatValue("joystickTolerance");
+ mToleranceSlider->setValue(tolerance);
+ // TRANSLATORS: joystick settings tab label
+ mToleranceLabel->setCaption(_("joystick dead zone: ")
+ + strprintf("%.2f", tolerance));
+ mToleranceLabel->setWidth(150);
+ mToleranceLabel->setHeight(20);
mNamesDropDown->setActionEventId("name");
mNamesDropDown->addActionListener(this);
+ mToleranceSlider->setActionEventId("toleranceslider");
+ mToleranceSlider->addActionListener(this);
if (joystick != nullptr)
{
@@ -96,10 +107,13 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) :
place(0, 0, mJoystickEnabled, 1, 1);
place(0, 1, mNamesDropDown, 1, 1);
- place(0, 2, mUseInactiveCheckBox, 1, 1);
- place(0, 3, mDetectButton, 1, 1);
- place(0, 4, mCalibrateLabel, 1, 1);
- place(0, 5, mCalibrateButton, 1, 1);
+
+ place(0, 2, mToleranceSlider, 1, 1);
+ place(1, 2, mToleranceLabel, 1, 1).setPadding(3);
+
+ place(0, 3, mUseHatForMovementCheckBox, 1, 1);
+ place(0, 4, mUseInactiveCheckBox, 1, 1);
+ place(0, 5, mDetectButton, 1, 1);
setDimension(Rect(0, 0, 365, 75));
}
@@ -121,6 +135,13 @@ void Setup_Joystick::action(const ActionEvent &event)
if (joystick != nullptr)
joystick->setNumber(mNamesDropDown->getSelected());
}
+ else if (source == mToleranceSlider)
+ {
+ const float tolerance = mToleranceSlider->getValue();
+ // TRANSLATORS: joystick settings tab label
+ mToleranceLabel->setCaption(_("joystick dead zone: ")
+ + strprintf("%.2f", tolerance));
+ }
else if (source == mDetectButton)
{
Joystick::detect();
@@ -130,36 +151,11 @@ void Setup_Joystick::action(const ActionEvent &event)
else
mNamesDropDown->setSelected(0);
}
- else
- {
- if (joystick == nullptr)
- return;
-
- if (joystick->isCalibrating())
- {
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton->setCaption(_("Calibrate"));
- mCalibrateLabel->setCaption
- // TRANSLATORS: joystick settings tab label
- (_("Press the button to start calibration"));
- joystick->finishCalibration();
- }
- else
- {
- // TRANSLATORS: joystick settings tab button
- mCalibrateButton->setCaption(_("Stop"));
- mCalibrateLabel->setCaption(
- // TRANSLATORS: joystick settings tab label
- _("Rotate the stick and don't press buttons"));
- joystick->startCalibration();
- }
- }
}
void Setup_Joystick::setTempEnabled(const bool sel)
{
Joystick::setEnabled(sel);
- mCalibrateButton->setEnabled(sel);
if (joystick != nullptr)
{
if (sel)
@@ -186,6 +182,16 @@ void Setup_Joystick::apply()
config.setValue("joystickEnabled", Joystick::isEnabled());
- config.setValue("useInactiveJoystick", mUseInactiveCheckBox->isSelected());
- joystick->setUseInactive(mUseInactiveCheckBox->isSelected());
+ config.setValue("useHatForMovement",
+ mUseHatForMovementCheckBox->isSelected());
+ joystick->setUseHatForMovement(
+ mUseHatForMovementCheckBox->isSelected());
+ config.setValue("useInactiveJoystick",
+ mUseInactiveCheckBox->isSelected());
+ joystick->setUseInactive(
+ mUseInactiveCheckBox->isSelected());
+
+ float tolerance = mToleranceSlider->getValue();
+ config.setValue("joystickTolerance", tolerance);
+ joystick->setTolerance(tolerance);
}
diff --git a/src/gui/widgets/tabs/setup_joystick.h b/src/gui/widgets/tabs/setup_joystick.h
index 174cd82b2..2c138daf5 100644
--- a/src/gui/widgets/tabs/setup_joystick.h
+++ b/src/gui/widgets/tabs/setup_joystick.h
@@ -31,6 +31,7 @@ class CheckBox;
class DropDown;
class Label;
class NamesModel;
+class Slider;
class Setup_Joystick final : public SetupTab
{
@@ -50,12 +51,13 @@ class Setup_Joystick final : public SetupTab
void setTempEnabled(const bool sel);
private:
- Label *mCalibrateLabel A_NONNULLPOINTER;
- Button *mCalibrateButton A_NONNULLPOINTER;
Button *mDetectButton A_NONNULLPOINTER;
CheckBox *mJoystickEnabled A_NONNULLPOINTER;
NamesModel *mNamesModel A_NONNULLPOINTER;
DropDown *mNamesDropDown A_NONNULLPOINTER;
+ Label *mToleranceLabel A_NONNULLPOINTER;
+ Slider *mToleranceSlider A_NONNULLPOINTER;
+ CheckBox *mUseHatForMovementCheckBox A_NONNULLPOINTER;
CheckBox *mUseInactiveCheckBox A_NONNULLPOINTER;
bool mOriginalJoystickEnabled A_NONNULLPOINTER;
};
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index a3b777655..15363883f 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -1246,8 +1246,6 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &caption,
if ((gui != nullptr) && !playerRelations.isGoodName(nick))
ret->setLabelFont(gui->getSecureFont());
mWhispers[tempNick] = ret;
- if (config.getBoolValue("showChatHistory"))
- ret->loadFromLogFile(nick);
}
if (switchTo)
@@ -1330,8 +1328,6 @@ ChatTab *ChatWindow::addChannelTab(const std::string &name,
ret = new ChannelTab(this, name);
mChannels[tempName] = ret;
ret->setAllowHighlight(false);
- if (config.getBoolValue("showChatHistory"))
- ret->loadFromLogFile(name);
}
if (switchTo)
diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp
index d1ceb1ad9..7ef2bc6e8 100644
--- a/src/gui/windows/quitdialog.cpp
+++ b/src/gui/windows/quitdialog.cpp
@@ -210,6 +210,7 @@ void QuitDialog::keyPressed(KeyEvent &event)
{
const InputActionT actionId = event.getActionId();
int dir = 0;
+ bool consume = true;
PRAGMA45(GCC diagnostic push)
PRAGMA45(GCC diagnostic ignored "-Wswitch-enum")
@@ -229,10 +230,14 @@ void QuitDialog::keyPressed(KeyEvent &event)
dir = 1;
break;
default:
+ consume = false;
break;
}
PRAGMA45(GCC diagnostic pop)
+ if (consume)
+ event.consume();
+
if (dir != 0)
{
STD_VECTOR<RadioButton*>::const_iterator it = mOptions.begin();