summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/setup_video.cpp21
-rw-r--r--src/gui/setup_video.h3
-rw-r--r--src/gui/setup_visual.cpp6
-rw-r--r--src/gui/setup_visual.h1
-rw-r--r--src/gui/widgets/horizontcontainer.cpp7
-rw-r--r--src/gui/widgets/horizontcontainer.h2
-rw-r--r--src/gui/widgets/setupitem.cpp98
-rw-r--r--src/gui/widgets/setupitem.h34
8 files changed, 149 insertions, 23 deletions
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 31060dcfd..65fb460e5 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -275,7 +275,6 @@ Setup_Video::Setup_Video():
mOpenGLEnabled(config.getIntValue("opengl")),
mCustomCursorEnabled(config.getBoolValue("customcursor")),
mParticleEffectsEnabled(config.getBoolValue("particleeffects")),
- mOpacity(config.getFloatValue("guialpha")),
mFps(config.getIntValue("fpslimit")),
mAltFps(config.getIntValue("altfpslimit")),
mEnableResize(config.getBoolValue("enableresize")),
@@ -293,7 +292,6 @@ Setup_Video::Setup_Video():
mNoFrameCheckBox(new CheckBox(_("No frame"), mNoFrame)),
mSpeechSlider(new Slider(0, 3)),
mSpeechLabel(new Label("")),
- mAlphaSlider(new Slider(0.1, 1.0)),
mFpsCheckBox(new CheckBox(_("FPS limit:"))),
mFpsSlider(new Slider(2, 160)),
mFpsLabel(new Label),
@@ -314,7 +312,6 @@ Setup_Video::Setup_Video():
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
speechLabel = new Label(_("Overhead text"));
- alphaLabel = new Label(_("Gui opacity"));
overlayDetailLabel = new Label(_("Ambient FX"));
particleDetailLabel = new Label(_("Particle detail"));
@@ -328,9 +325,6 @@ Setup_Video::Setup_Video():
mOpenGLDropDown->setSelected(0);
#endif
- mAlphaSlider->setValue(mOpacity);
- mAlphaSlider->setWidth(90);
-
mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None"));
mFpsLabel->setWidth(60);
mAltFpsLabel->setCaption(_("Alt FPS limit: ") + (mAltFps > 0
@@ -350,7 +344,6 @@ Setup_Video::Setup_Video():
mModeList->setActionEventId("videomode");
mCustomCursorCheckBox->setActionEventId("customcursor");
mParticleEffectsCheckBox->setActionEventId("particleeffects");
- mAlphaSlider->setActionEventId("guialpha");
mFpsCheckBox->setActionEventId("fpslimitcheckbox");
mSpeechSlider->setActionEventId("speech");
mFpsSlider->setActionEventId("fpslimitslider");
@@ -366,7 +359,6 @@ Setup_Video::Setup_Video():
mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
mParticleEffectsCheckBox->addActionListener(this);
- mAlphaSlider->addActionListener(this);
mFpsCheckBox->addActionListener(this);
mSpeechSlider->addActionListener(this);
mFpsSlider->addActionListener(this);
@@ -406,8 +398,8 @@ Setup_Video::Setup_Video():
// place(1, 6, mPickupChatCheckBox, 1);
// place(2, 6, mPickupParticleCheckBox, 2);
- place(0, 7, mAlphaSlider);
- place(1, 7, alphaLabel, 3);
+// place(0, 7, mAlphaSlider);
+// place(1, 7, alphaLabel, 3);
place(0, 9, mFpsSlider);
place(1, 9, mFpsCheckBox).setPadding(3);
@@ -530,7 +522,6 @@ void Setup_Video::apply()
mSpeechMode = static_cast<Being::Speech>(
config.getIntValue("speech"));
- mOpacity = config.getFloatValue("guialpha");
mOverlayDetail = config.getIntValue("OverlayDetail");
mOpenGLEnabled = config.getIntValue("opengl");
mEnableResize = config.getBoolValue("enableresize");
@@ -549,7 +540,6 @@ void Setup_Video::cancel()
mAltFpsSlider->setValue(mAltFps);
mAltFpsSlider->setEnabled(mAltFps > 0);
mSpeechSlider->setValue(mSpeechMode);
- mAlphaSlider->setValue(mOpacity);
mOverlayDetailSlider->setValue(mOverlayDetail);
mParticleDetailSlider->setValue(mParticleDetail);
mFpsLabel->setCaption(mFpsCheckBox->isSelected()
@@ -570,8 +560,6 @@ void Setup_Video::cancel()
config.setValue("customcursor", mCustomCursorEnabled);
config.setValue("particleeffects", mParticleEffectsEnabled);
config.setValue("speech", static_cast<int>(mSpeechMode));
- config.setValue("guialpha", mOpacity);
- Image::setEnableAlpha(mOpacity != 1.0f);
config.setValue("opengl", mOpenGLEnabled);
config.setValue("enableresize", mEnableResize);
config.setValue("noframe", mNoFrame);
@@ -635,11 +623,6 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
mDialog = nullptr;
}
- else if (id == "guialpha")
- {
- config.setValue("guialpha", mAlphaSlider->getValue());
- Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f);
- }
else if (id == "customcursor")
{
config.setValue("customcursor", mCustomCursorCheckBox->isSelected());
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index ad6ca12d7..32a5d444c 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -57,7 +57,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
int mOpenGLEnabled;
bool mCustomCursorEnabled;
bool mParticleEffectsEnabled;
- float mOpacity;
int mFps;
int mAltFps;
bool mEnableResize;
@@ -69,7 +68,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
OpenGLListModel *mOpenGLListModel;
gcn::Label *speechLabel;
- gcn::Label *alphaLabel;
gcn::Label *scrollRadiusLabel;
gcn::Label *scrollLazinessLabel;
gcn::Label *overlayDetailLabel;
@@ -86,7 +84,6 @@ class Setup_Video : public SetupTab, public gcn::KeyListener
gcn::Slider *mSpeechSlider;
gcn::Label *mSpeechLabel;
- gcn::Slider *mAlphaSlider;
gcn::CheckBox *mFpsCheckBox;
gcn::Slider *mFpsSlider;
gcn::Label *mFpsLabel;
diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp
index 22894e267..cc713effa 100644
--- a/src/gui/setup_visual.cpp
+++ b/src/gui/setup_visual.cpp
@@ -32,6 +32,8 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/setupitem.h"
+#include "resources/image.h"
+
#include "configuration.h"
#include "localplayer.h"
#include "logger.h"
@@ -58,11 +60,15 @@ Setup_Visual::Setup_Visual()
new SetupItemCheckBox(_("Grab mouse and keyboard input"),
"", "grabinput", this, "grabinputEvent");
+ new SetupItemSlider(_("Gui opacity"), "", "guialpha",
+ this, "guialphaEvent", 0.1, 1.0);
+
setDimension(gcn::Rectangle(0, 0, 550, 350));
}
void Setup_Visual::apply()
{
SetupTabScroll::apply();
+ Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f);
Client::applyGrabMode();
}
diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h
index f5001b9e4..b8715f409 100644
--- a/src/gui/setup_visual.h
+++ b/src/gui/setup_visual.h
@@ -35,6 +35,7 @@ class Setup_Visual : public SetupTabScroll
Setup_Visual();
void apply();
+
};
#endif
diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp
index c128ea550..5bf81c5d8 100644
--- a/src/gui/widgets/horizontcontainer.cpp
+++ b/src/gui/widgets/horizontcontainer.cpp
@@ -34,11 +34,16 @@ HorizontContainer::HorizontContainer(int height, int spacing):
void HorizontContainer::add(gcn::Widget *widget)
{
+ add(widget, mSpacing);
+}
+
+void HorizontContainer::add(gcn::Widget *widget, int spacing)
+{
if (!widget)
return;
Container::add(widget);
- widget->setPosition(mLastX, mSpacing);
+ widget->setPosition(mLastX, spacing);
mCount++;
mLastX += widget->getWidth() + 2 * mSpacing;
}
diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h
index 7439672dc..8e1d082ac 100644
--- a/src/gui/widgets/horizontcontainer.h
+++ b/src/gui/widgets/horizontcontainer.h
@@ -38,6 +38,8 @@ class HorizontContainer : public Container, public gcn::WidgetListener
virtual void add(gcn::Widget *widget);
+ virtual void add(gcn::Widget *widget, int spacing);
+
virtual void clear();
void widgetResized(const gcn::Event &event);
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 56ce0a25a..1d6bf5916 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -33,6 +33,7 @@
#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
+#include "gui/widgets/slider.h"
#include "gui/widgets/tabbedarea.h"
#include "gui/widgets/textfield.h"
#include "gui/widgets/vertcontainer.h"
@@ -588,3 +589,100 @@ void SetupItemDropDown::toWidget()
mDropDown->setSelectedString(mValue);
}
+
+
+
+
+
+
+SetupItemSlider::SetupItemSlider(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, double min, double max,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mSlider(nullptr),
+ mMin(min),
+ mMax(max)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemSlider::SetupItemSlider(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, double min, double max,
+ std::string def, bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(nullptr),
+ mLabel(nullptr),
+ mSlider(nullptr),
+ mMin(min),
+ mMax(max)
+{
+ mValueType = VSTR;
+ createControls();
+}
+
+SetupItemSlider::~SetupItemSlider()
+{
+ mHorizont = nullptr;
+ mWidget = nullptr;
+ mSlider = nullptr;
+ mLabel = nullptr;
+}
+
+void SetupItemSlider::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ mLabel = new Label(mText);
+ mSlider = new Slider(mMin, mMax);
+ mSlider->setActionEventId(mEventName);
+ mSlider->addActionListener(mParent);
+ mSlider->setValue(atof(mValue.c_str()));
+ mSlider->setHeight(30);
+
+ mWidget = mSlider;
+ mSlider->setWidth(150);
+ mSlider->setHeight(40);
+ mHorizont->add(mLabel);
+ mHorizont->add(mSlider, -10);
+
+ mParent->getContainer()->add2(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+}
+
+void SetupItemSlider::fromWidget()
+{
+ if (!mSlider)
+ return;
+
+ mValue = toString(mSlider->getValue());
+}
+
+void SetupItemSlider::toWidget()
+{
+ if (!mSlider)
+ return;
+
+ mSlider->setValue(atof(mValue.c_str()));
+}
+
+void SetupItemSlider::action(const gcn::ActionEvent &event A_UNUSED)
+{
+ fromWidget();
+}
+
+void SetupItemSlider::apply(std::string eventName)
+{
+ if (eventName != mEventName)
+ return;
+
+ fromWidget();
+ save();
+}
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index 71856d6e2..220a55494 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -41,6 +41,7 @@ class EditDialog;
class HorizontContainer;
class IntTextField;
class Label;
+class Slider;
class TextField;
class SetupItem : public gcn::ActionListener
@@ -264,4 +265,37 @@ class SetupItemDropDown : public SetupItem
DropDown *mDropDown;
};
+class SetupItemSlider : public SetupItem
+{
+ public:
+ SetupItemSlider(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, double min, double max,
+ bool mainConfig = true);
+
+ SetupItemSlider(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, double min, double max,
+ std::string def, bool mainConfig = true);
+
+ ~SetupItemSlider();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ Slider *mSlider;
+ double mMin;
+ double mMax;
+};
+
#endif