summaryrefslogtreecommitdiff
path: root/src/quicktune.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-12 21:27:29 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-12 21:27:29 +0200
commit2c9bb06516418b99c1eac957cfae9d84c9bef954 (patch)
tree8794a1a4b32aeb57f91f8444eead28bed1579b8a /src/quicktune.cpp
parent18c4a901018f3487825ee6ab30d014d9795b2750 (diff)
downloadminetest-2c9bb06516418b99c1eac957cfae9d84c9bef954.tar.gz
minetest-2c9bb06516418b99c1eac957cfae9d84c9bef954.tar.bz2
minetest-2c9bb06516418b99c1eac957cfae9d84c9bef954.zip
Make finish quicktune and leave it unused (as intended)
Diffstat (limited to 'src/quicktune.cpp')
-rw-r--r--src/quicktune.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/src/quicktune.cpp b/src/quicktune.cpp
index 66b9804df..e41fb73af 100644
--- a/src/quicktune.cpp
+++ b/src/quicktune.cpp
@@ -20,6 +20,32 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "quicktune.h"
#include <jmutex.h>
#include <jmutexautolock.h>
+#include "utility.h"
+
+std::string QuicktuneValue::getString()
+{
+ switch(type){
+ case QVT_NONE:
+ return "(none)";
+ case QVT_FLOAT:
+ return ftos(value_QVT_FLOAT.current);
+ }
+ return "<invalid type>";
+}
+void QuicktuneValue::relativeAdd(float amount)
+{
+ switch(type){
+ case QVT_NONE:
+ break;
+ case QVT_FLOAT:
+ value_QVT_FLOAT.current += amount * (value_QVT_FLOAT.max - value_QVT_FLOAT.min);
+ if(value_QVT_FLOAT.current > value_QVT_FLOAT.max)
+ value_QVT_FLOAT.current = value_QVT_FLOAT.max;
+ if(value_QVT_FLOAT.current < value_QVT_FLOAT.min)
+ value_QVT_FLOAT.current = value_QVT_FLOAT.min;
+ break;
+ }
+}
static std::map<std::string, QuicktuneValue> g_values;
static std::vector<std::string> g_names;
@@ -38,13 +64,6 @@ std::vector<std::string> getQuicktuneNames()
return g_names;
}
-/*std::map<std::string, QuicktuneValue> getQuicktuneValues()
-{
- makeMutex();
- JMutexAutoLock lock(*g_mutex);
- return g_values;
-}*/
-
QuicktuneValue getQuicktuneValue(const std::string &name)
{
makeMutex();
@@ -52,7 +71,7 @@ QuicktuneValue getQuicktuneValue(const std::string &name)
std::map<std::string, QuicktuneValue>::iterator i = g_values.find(name);
if(i == g_values.end()){
QuicktuneValue val;
- val.type = QUICKTUNE_NONE;
+ val.type = QVT_NONE;
return val;
}
return i->second;
@@ -63,6 +82,7 @@ void setQuicktuneValue(const std::string &name, const QuicktuneValue &val)
makeMutex();
JMutexAutoLock lock(*g_mutex);
g_values[name] = val;
+ g_values[name].modified = true;
}
void updateQuicktuneValue(const std::string &name, QuicktuneValue &val)
@@ -76,12 +96,11 @@ void updateQuicktuneValue(const std::string &name, QuicktuneValue &val)
return;
}
QuicktuneValue &ref = i->second;
- switch(val.type){
- case QUICKTUNE_NONE:
- break;
- case QUICKTUNE_FLOAT:
- val.value_float.current = ref.value_float.current;
- break;
+ if(ref.modified)
+ val = ref;
+ else{
+ ref = val;
+ ref.modified = false;
}
}