summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tabs
diff options
context:
space:
mode:
authorasuratva <asuratva@proton.me>2024-05-18 10:58:37 +0000
committerasuratva <asuratva@proton.me>2024-05-18 10:58:37 +0000
commit1d7ee3161693ed016264a4940778a6e4b2258e38 (patch)
tree059f68cc39a725a0bc64538e5771ef3525aa6ec6 /src/gui/widgets/tabs
parent9294f5a1ba84c7a4e947ab94a2645625e8a6171d (diff)
parent5570d9d1c2b1b5fba50283ec443088430332bb86 (diff)
downloadplus-1d7ee3161693ed016264a4940778a6e4b2258e38.tar.gz
plus-1d7ee3161693ed016264a4940778a6e4b2258e38.tar.bz2
plus-1d7ee3161693ed016264a4940778a6e4b2258e38.tar.xz
plus-1d7ee3161693ed016264a4940778a6e4b2258e38.zip
Merge branch plus:master into masterHEADmaster
Diffstat (limited to 'src/gui/widgets/tabs')
-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
4 files changed, 51 insertions, 42 deletions
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;
};