summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-02-21 03:33:54 +0300
committerAndrei Karas <akaras@inbox.ru>2012-02-21 03:33:54 +0300
commite4dabfe2b75a20378bdb1bf32b53249b5d55740b (patch)
tree8c14cc39a4f0a5b730d377a1d89b0304c9b8122d /src
parent2eef004b8b70861fd377ad50393a9a0ccbbbc152 (diff)
downloadmv-e4dabfe2b75a20378bdb1bf32b53249b5d55740b.tar.gz
mv-e4dabfe2b75a20378bdb1bf32b53249b5d55740b.tar.bz2
mv-e4dabfe2b75a20378bdb1bf32b53249b5d55740b.tar.xz
mv-e4dabfe2b75a20378bdb1bf32b53249b5d55740b.zip
Bit cleanup visual settings page.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp20
-rw-r--r--src/client.h2
-rw-r--r--src/defaults.cpp2
-rw-r--r--src/gui/setup_visual.cpp30
-rw-r--r--src/gui/setup_visual.h2
-rw-r--r--src/gui/widgets/setupitem.cpp30
-rw-r--r--src/gui/widgets/setupitem.h12
7 files changed, 59 insertions, 39 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 949dbacd2..d0c573e13 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -563,6 +563,7 @@ void Client::gameInit()
}
applyGrabMode();
+ applyGamma();
// Initialize for drawing
mainGraphics->_beginDraw();
@@ -665,6 +666,8 @@ void Client::gameInit()
setFramerate(fpsLimit);
config.addListener("fpslimit", this);
config.addListener("guialpha", this);
+ config.addListener("gamma", this);
+ config.addListener("particleEmitterSkip", this);
setGuiAlpha(config.getFloatValue("guialpha"));
optionChanged("fpslimit");
@@ -704,6 +707,8 @@ void Client::gameClear()
logger->log1("Quitting1");
config.removeListener("fpslimit", this);
config.removeListener("guialpha", this);
+ config.removeListener("gamma", this);
+ config.removeListener("particleEmitterSkip", this);
SDL_RemoveTimer(mLogicCounterId);
SDL_RemoveTimer(mSecondsCounterId);
@@ -1492,6 +1497,15 @@ void Client::optionChanged(const std::string &name)
else if (name == "guialpha")
{
setGuiAlpha(config.getFloatValue("guialpha"));
+ Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f);
+ }
+ else if (name == "gamma")
+ {
+ applyGamma();
+ }
+ else if (name == "particleEmitterSkip")
+ {
+ Particle::emitterSkip = config.getIntValue("particleEmitterSkip") + 1;
}
}
@@ -2437,3 +2451,9 @@ void Client::applyGrabMode()
SDL_WM_GrabInput(config.getBoolValue("grabinput")
? SDL_GRAB_ON : SDL_GRAB_OFF);
}
+
+void Client::applyGamma()
+{
+ float val = config.getFloatValue("gamma");
+ SDL_SetGamma(val, val, val);
+} \ No newline at end of file
diff --git a/src/client.h b/src/client.h
index ba6fde480..922b24caf 100644
--- a/src/client.h
+++ b/src/client.h
@@ -275,6 +275,8 @@ public:
static void applyGrabMode();
+ void applyGamma();
+
void optionChanged(const std::string &name);
void action(const gcn::ActionEvent &event);
diff --git a/src/defaults.cpp b/src/defaults.cpp
index b21941bfb..865330827 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -226,6 +226,8 @@ DefaultsData* getConfigDefaults()
AddDEF(configData, "enableresize", true);
AddDEF(configData, "noframe", false);
AddDEF(configData, "groupFriends", true);
+ AddDEF(configData, "grabinput", false);
+ AddDEF(configData, "gamma", 1);
return configData;
}
diff --git a/src/gui/setup_visual.cpp b/src/gui/setup_visual.cpp
index 9c172da04..5e072b53b 100644
--- a/src/gui/setup_visual.cpp
+++ b/src/gui/setup_visual.cpp
@@ -62,7 +62,7 @@ Setup_Visual::Setup_Visual()
"", "grabinput", this, "grabinputEvent");
new SetupItemSlider(_("Gui opacity"), "", "guialpha",
- this, "guialphaEvent", 0.1, 1.0);
+ this, "guialphaEvent", 0.1, 1.0, 150, true);
mSpeachList = new SetupItemNames();
mSpeachList->push_back(_("No text"));
@@ -89,7 +89,10 @@ Setup_Visual::Setup_Visual()
mParticleList->push_back(_("max"));
(new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip",
this, "particleEmitterSkipEvent", 0, 3,
- mParticleList))->setInvertValue(3);
+ mParticleList, true))->setInvertValue(3);
+
+ new SetupItemSlider(_("Gamma"), "", "gamma",
+ this, "gammeEvent", 1, 20, 350, true);
setDimension(gcn::Rectangle(0, 0, 550, 350));
}
@@ -107,28 +110,5 @@ Setup_Visual::~Setup_Visual()
void Setup_Visual::apply()
{
SetupTabScroll::apply();
- Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f);
Client::applyGrabMode();
}
-
-void Setup_Visual::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == "guialphaEvent")
- {
- Slider *slider = static_cast<Slider*>(event.getSource());
- if (slider)
- {
- config.setValue("guialpha", slider->getValue());
- Image::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f);
- }
- }
- else if (event.getId() == "particleEmitterSkipEvent")
- {
- Slider *slider = static_cast<Slider*>(event.getSource());
- if (slider)
- {
- int val = static_cast<int>(slider->getValue());
- Particle::emitterSkip = 4 - val;
- }
- }
-}
diff --git a/src/gui/setup_visual.h b/src/gui/setup_visual.h
index 60d8ac787..30ae18645 100644
--- a/src/gui/setup_visual.h
+++ b/src/gui/setup_visual.h
@@ -39,8 +39,6 @@ class Setup_Visual : public SetupTabScroll
void apply();
- void action(const gcn::ActionEvent &event A_UNUSED);
-
private:
SetupItemNames *mSpeachList;
diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp
index 581d9f239..490c046c3 100644
--- a/src/gui/widgets/setupitem.cpp
+++ b/src/gui/widgets/setupitem.cpp
@@ -597,13 +597,15 @@ void SetupItemDropDown::toWidget()
SetupItemSlider::SetupItemSlider(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
std::string eventName, double min, double max,
- bool mainConfig) :
+ int width, bool onTheFly, bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, mainConfig),
mHorizont(nullptr),
mLabel(nullptr),
mSlider(nullptr),
mMin(min),
- mMax(max)
+ mMax(max),
+ mWidth(width),
+ mOnTheFly(onTheFly)
{
mValueType = VSTR;
createControls();
@@ -612,13 +614,16 @@ SetupItemSlider::SetupItemSlider(std::string text, std::string description,
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) :
+ std::string def, int width, bool onTheFly,
+ bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
mHorizont(nullptr),
mLabel(nullptr),
mSlider(nullptr),
mMin(min),
- mMax(max)
+ mMax(max),
+ mWidth(width),
+ mOnTheFly(onTheFly)
{
mValueType = VSTR;
createControls();
@@ -645,7 +650,7 @@ void SetupItemSlider::createControls()
mSlider->setHeight(30);
mWidget = mSlider;
- mSlider->setWidth(150);
+ mSlider->setWidth(mWidth);
mSlider->setHeight(40);
mHorizont->add(mLabel);
mHorizont->add(mSlider, -10);
@@ -675,6 +680,8 @@ void SetupItemSlider::toWidget()
void SetupItemSlider::action(const gcn::ActionEvent &event A_UNUSED)
{
fromWidget();
+ if (mOnTheFly)
+ save();
}
void SetupItemSlider::apply(std::string eventName)
@@ -689,7 +696,8 @@ void SetupItemSlider::apply(std::string eventName)
SetupItemSlider2::SetupItemSlider2(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
std::string eventName, int min, int max,
- SetupItemNames *values, bool mainConfig) :
+ SetupItemNames *values, bool onTheFly,
+ bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, mainConfig),
mHorizont(nullptr),
mLabel(nullptr),
@@ -699,7 +707,8 @@ SetupItemSlider2::SetupItemSlider2(std::string text, std::string description,
mMin(min),
mMax(max),
mInvert(false),
- mInvertValue(0)
+ mInvertValue(0),
+ mOnTheFly(onTheFly)
{
mValueType = VSTR;
createControls();
@@ -709,7 +718,7 @@ SetupItemSlider2::SetupItemSlider2(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
std::string eventName, int min, int max,
SetupItemNames *values, std::string def,
- bool mainConfig) :
+ bool onTheFly, bool mainConfig) :
SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
mHorizont(nullptr),
mLabel(nullptr),
@@ -719,7 +728,8 @@ SetupItemSlider2::SetupItemSlider2(std::string text, std::string description,
mMin(min),
mMax(max),
mInvert(false),
- mInvertValue(0)
+ mInvertValue(0),
+ mOnTheFly(onTheFly)
{
mValueType = VSTR;
createControls();
@@ -811,6 +821,8 @@ void SetupItemSlider2::action(const gcn::ActionEvent &event A_UNUSED)
{
fromWidget();
updateLabel();
+ if (mOnTheFly)
+ save();
}
void SetupItemSlider2::updateLabel()
diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h
index cf847f55d..b950d1488 100644
--- a/src/gui/widgets/setupitem.h
+++ b/src/gui/widgets/setupitem.h
@@ -270,12 +270,14 @@ class SetupItemSlider : public SetupItem
SetupItemSlider(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
std::string eventName, double min, double max,
+ int width = 150, bool onTheFly = false,
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);
+ std::string def, int width = 150,
+ bool onTheFly = false, bool mainConfig = true);
~SetupItemSlider();
@@ -297,6 +299,8 @@ class SetupItemSlider : public SetupItem
Slider *mSlider;
double mMin;
double mMax;
+ int mWidth;
+ bool mOnTheFly;
};
typedef std::vector<std::string> SetupItemNames;
@@ -309,13 +313,14 @@ class SetupItemSlider2 : public SetupItem
SetupItemSlider2(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
std::string eventName, int min, int max,
- SetupItemNames *values, bool mainConfig = true);
+ SetupItemNames *values, bool onTheFly = false,
+ bool mainConfig = true);
SetupItemSlider2(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
std::string eventName, int min, int max,
SetupItemNames *values, std::string def,
- bool mainConfig = true);
+ bool onTheFly = false, bool mainConfig = true);
~SetupItemSlider2();
@@ -345,6 +350,7 @@ class SetupItemSlider2 : public SetupItem
int mMax;
bool mInvert;
int mInvertValue;
+ bool mOnTheFly;
};
#endif