summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-26 20:19:39 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-08-26 20:19:39 +0000
commitbe3b639a879a5a8eb73b2e652683da222796af44 (patch)
tree35d5ed3957c283dbb49fd9b92112c7cc919b7ba9 /src/gui
parentef82a7df8aafb569f6db5e77ff2dd67fde860148 (diff)
downloadmana-be3b639a879a5a8eb73b2e652683da222796af44.tar.gz
mana-be3b639a879a5a8eb73b2e652683da222796af44.tar.bz2
mana-be3b639a879a5a8eb73b2e652683da222796af44.tar.xz
mana-be3b639a879a5a8eb73b2e652683da222796af44.zip
Applied patch by Pascal, adding sliders to configure the scrolling behaviour
and a checkbox to enable or disable the joystick.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/setup.cpp4
-rw-r--r--src/gui/setup_joystick.cpp57
-rw-r--r--src/gui/setup_joystick.h6
-rw-r--r--src/gui/setup_video.cpp78
-rw-r--r--src/gui/setup_video.h16
5 files changed, 144 insertions, 17 deletions
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 73b22e5a..1fe22ea6 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -43,7 +43,7 @@ Setup::Setup():
Window("Setup")
{
int width = 230;
- int height = 185;
+ int height = 225;
setContentSize(width, height);
const char *buttonNames[] = {
@@ -58,7 +58,7 @@ Setup::Setup():
}
TabbedContainer *panel = new TabbedContainer();
- panel->setDimension(gcn::Rectangle(5, 5, 220, 150));
+ panel->setDimension(gcn::Rectangle(5, 5, 220, 185));
panel->setOpaque(false);
SetupTab *tab;
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 36b0ee20..d9212728 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -26,22 +26,31 @@
#include <guichan/widgets/label.hpp>
#include "button.h"
-
+#include "checkbox.h"
+#include "../configuration.h"
#include "../joystick.h"
extern Joystick *joystick;
Setup_Joystick::Setup_Joystick():
mCalibrateLabel(new gcn::Label("Press the button to start calibration")),
- mCalibrateButton(new Button("Calibrate", "calibrate", this))
+ mCalibrateButton(new Button("Calibrate", "calibrate", this)),
+ mJoystickEnabled(new CheckBox("Enable joystick"))
{
setOpaque(false);
+ mJoystickEnabled->setPosition(10, 10);
+ mCalibrateLabel->setPosition(10, 25);
+ mCalibrateButton->setPosition(10, 30 + mCalibrateLabel->getHeight());
+
+ mOriginalJoystickEnabled = (joystick ? joystick->isEnabled() : false);
+ mJoystickEnabled->setMarked(mOriginalJoystickEnabled);
- mCalibrateLabel->setPosition(5, 10);
- mCalibrateButton->setPosition(10, 20 + mCalibrateLabel->getHeight());
+ mJoystickEnabled->setEventId("joystickEnabled");
+ mJoystickEnabled->addActionListener(this);
add(mCalibrateLabel);
add(mCalibrateButton);
+ add(mJoystickEnabled);
}
void Setup_Joystick::action(const std::string &event, gcn::Widget *widget)
@@ -50,13 +59,37 @@ void Setup_Joystick::action(const std::string &event, gcn::Widget *widget)
return;
}
- if (joystick->isCalibrating()) {
- mCalibrateButton->setCaption("Calibrate");
- mCalibrateLabel->setCaption("Press the button to start calibration");
- joystick->finishCalibration();
- } else {
- mCalibrateButton->setCaption("Stop");
- mCalibrateLabel->setCaption("Rotate the stick");
- joystick->startCalibration();
+ if (event == "joystickEnabled")
+ {
+ joystick->setEnabled(mJoystickEnabled->isMarked());
+ }
+ else
+ {
+ if (joystick->isCalibrating()) {
+ mCalibrateButton->setCaption("Calibrate");
+ mCalibrateLabel->setCaption(
+ "Press the button to start calibration");
+ joystick->finishCalibration();
+ } else {
+ mCalibrateButton->setCaption("Stop");
+ mCalibrateLabel->setCaption("Rotate the stick");
+ joystick->startCalibration();
+ }
}
}
+
+void Setup_Joystick::cancel()
+{
+ if (joystick)
+ {
+ joystick->setEnabled(mOriginalJoystickEnabled);
+ }
+ mJoystickEnabled->setMarked(mOriginalJoystickEnabled);
+}
+
+void Setup_Joystick::apply()
+{
+ config.setValue("joystickEnabled",
+ joystick ? joystick->isEnabled() : false);
+}
+
diff --git a/src/gui/setup_joystick.h b/src/gui/setup_joystick.h
index da773c8f..4cc2b3d9 100644
--- a/src/gui/setup_joystick.h
+++ b/src/gui/setup_joystick.h
@@ -35,14 +35,16 @@ class Setup_Joystick : public SetupTab, public gcn::ActionListener
public:
Setup_Joystick();
- void apply() {}
- void cancel() {}
+ void apply();
+ void cancel();
void action(const std::string& eventId, gcn::Widget* widget);
private:
gcn::Label *mCalibrateLabel;
gcn::Button *mCalibrateButton;
+ bool mOriginalJoystickEnabled;
+ gcn::CheckBox *mJoystickEnabled;
};
#endif
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 9eb94520..fc2c0c78 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -114,7 +114,13 @@ Setup_Video::Setup_Video():
mAlphaSlider(new Slider(0.2, 1.0)),
mFpsCheckBox(new CheckBox("FPS Limit: ")),
mFpsSlider(new Slider(10, 200)),
- mFpsField(new TextField())
+ mFpsField(new TextField()),
+ mOriginalScrollLaziness((int) config.getValue("ScrollLaziness", 0)),
+ mScrollLazinessSlider(new Slider(0, 100)),
+ mScrollLazinessField(new TextField()),
+ mOriginalScrollRadius((int) config.getValue("ScrollRadius", 0)),
+ mScrollRadiusSlider(new Slider(0, 100)),
+ mScrollRadiusField(new TextField())
{
setOpaque(false);
@@ -152,12 +158,36 @@ Setup_Video::Setup_Video():
mAlphaSlider->setEventId("guialpha");
mFpsCheckBox->setEventId("fpslimitcheckbox");
mFpsSlider->setEventId("fpslimitslider");
+ mScrollRadiusSlider->setEventId("scrollradiusslider");
+ mScrollRadiusField->setEventId("scrollradiusfield");
+ mScrollLazinessSlider->setEventId("scrolllazinessslider");
+ mScrollLazinessField->setEventId("scrolllazinessfield");
mCustomCursorCheckBox->addActionListener(this);
mAlphaSlider->addActionListener(this);
mFpsCheckBox->addActionListener(this);
mFpsSlider->addActionListener(this);
mFpsField->addKeyListener(this);
+ mScrollRadiusSlider->addActionListener(this);
+ mScrollRadiusField->addKeyListener(this);
+ mScrollLazinessSlider->addActionListener(this);
+ mScrollLazinessField->addKeyListener(this);
+
+ mScrollRadiusSlider->setDimension(gcn::Rectangle(10, 120, 75, 10));
+ gcn::Label *scrollRadiusLabel = new gcn::Label("Scroll radius");
+ scrollRadiusLabel->setPosition(90, 120);
+ mScrollRadiusField->setPosition(180, 120);
+ mScrollRadiusField->setWidth(30);
+ mScrollRadiusField->setText(toString(mOriginalScrollRadius));
+ mScrollRadiusSlider->setValue(mOriginalScrollRadius);
+
+ mScrollLazinessSlider->setDimension(gcn::Rectangle(10, 140, 75, 10));
+ gcn::Label *scrollLazinessLabel = new gcn::Label("Scroll laziness");
+ scrollLazinessLabel->setPosition(90, 140);
+ mScrollLazinessField->setPosition(180, 140);
+ mScrollLazinessField->setWidth(30);
+ mScrollLazinessField->setText(toString(mOriginalScrollLaziness));
+ mScrollLazinessSlider->setValue(mOriginalScrollLaziness);
add(scrollArea);
add(mFsCheckBox);
@@ -168,6 +198,12 @@ Setup_Video::Setup_Video():
add(mFpsCheckBox);
add(mFpsSlider);
add(mFpsField);
+ add(mScrollRadiusSlider);
+ add(scrollRadiusLabel);
+ add(mScrollRadiusField);
+ add(mScrollLazinessSlider);
+ add(scrollLazinessLabel);
+ add(mScrollLazinessField);
}
Setup_Video::~Setup_Video()
@@ -224,6 +260,27 @@ void Setup_Video::apply()
mOpenGLEnabled = config.getValue("opengl", 0);
}
+int
+Setup_Video::updateSlider(gcn::Slider *slider, gcn::TextField *field,
+ const std::string &configName)
+{
+ int value;
+ std::stringstream temp(field->getText());
+ temp >> value;
+ if (value < slider->getScaleStart())
+ {
+ value = (int) slider->getScaleStart();
+ }
+ else if (value > slider->getScaleEnd())
+ {
+ value = (int) slider->getScaleEnd();
+ }
+ field->setText(toString(value));
+ slider->setValue(value);
+ config.setValue(configName, value);
+ return value;
+}
+
void Setup_Video::cancel()
{
mFsCheckBox->setMarked(mFullScreenEnabled);
@@ -231,6 +288,11 @@ void Setup_Video::cancel()
mCustomCursorCheckBox->setMarked(mCustomCursorEnabled);
mAlphaSlider->setValue(mOpacity);
+ mScrollRadiusField->setText(toString(mOriginalScrollRadius));
+ mScrollLazinessField->setText(toString(mOriginalScrollLaziness));
+ updateSlider(mScrollRadiusSlider, mScrollRadiusField, "ScrollRadius");
+ updateSlider(mScrollLazinessSlider, mScrollLazinessField, "ScrollLaziness");
+
config.setValue("screen", mFullScreenEnabled ? 1 : 0);
config.setValue("customcursor", mCustomCursorEnabled ? 1 : 0);
config.setValue("guialpha", mOpacity);
@@ -253,6 +315,18 @@ void Setup_Video::action(const std::string &event, gcn::Widget *widget)
mFps = (int)mFpsSlider->getValue();
mFpsField->setText(toString(mFps));
}
+ else if (event == "scrollradiusslider")
+ {
+ int val = (int)mScrollRadiusSlider->getValue();
+ mScrollRadiusField->setText(toString(val));
+ config.setValue("ScrollRadius", val);
+ }
+ else if (event == "scrolllazinessslider")
+ {
+ int val = (int)mScrollLazinessSlider->getValue();
+ mScrollLazinessField->setText(toString(val));
+ config.setValue("ScrollLaziness", val);
+ }
else if (event == "fpslimitcheckbox")
{
if (mFpsCheckBox->isMarked())
@@ -292,4 +366,6 @@ void Setup_Video::keyPress(const gcn::Key &key)
mFpsField->setText("");
mFps = 0;
}
+ updateSlider(mScrollRadiusSlider, mScrollRadiusField, "ScrollRadius");
+ updateSlider(mScrollLazinessSlider, mScrollLazinessField, "ScrollLaziness");
}
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 9aef8834..3b5c00a5 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -59,10 +59,26 @@ class Setup_Video : public SetupTab, public gcn::ActionListener,
gcn::CheckBox *mFsCheckBox;
gcn::CheckBox *mOpenGLCheckBox;
gcn::CheckBox *mCustomCursorCheckBox;
+
gcn::Slider *mAlphaSlider;
gcn::CheckBox *mFpsCheckBox;
gcn::Slider *mFpsSlider;
gcn::TextField *mFpsField;
+
+ int mOriginalScrollLaziness;
+ gcn::Slider *mScrollLazinessSlider;
+ gcn::TextField *mScrollLazinessField;
+
+ int mOriginalScrollRadius;
+ gcn::Slider *mScrollRadiusSlider;
+ gcn::TextField *mScrollRadiusField;
+
+ void
+ updateSliders(bool originalValues);
+
+ int
+ updateSlider(gcn::Slider *slider, gcn::TextField *field,
+ const std::string &configName);
};
#endif