3 Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef QUICKTUNE_HEADER
21 #define QUICKTUNE_HEADER
23 #include "irrlichttypes.h"
29 enum QuicktuneValueType{
35 QuicktuneValueType type;
45 std::vector<std::string> getQuicktuneNames();
46 //std::map<std::string, QuicktuneValue> getQuicktuneNames();
47 QuicktuneValue getQuicktuneValue(const std::string &name);
48 void setQuicktuneValue(const std::string &name, const QuicktuneValue &val);
50 class QuicktuneShortcutter
53 std::vector<std::string> m_names;
55 std::string m_message;
57 std::string getMessage()
59 std::string s = m_message;
63 std::string getSelectedName()
65 if(m_selected_i < m_names.size())
66 return m_names[m_selected_i];
71 m_names = getQuicktuneNames();
72 if(m_selected_i < m_names.size()-1)
76 m_message = std::string("Selected \"")+getSelectedName()+"\"";
80 m_names = getQuicktuneNames();
84 m_selected_i = m_names.size()-1;
85 m_message = std::string("Selected \"")+getSelectedName()+"\"";
89 QuicktuneValue val = getQuicktuneValue(getSelectedName());
94 val.value_float.current += 0.05 * (val.value_float.max - val.value_float.min);
95 if(val.value_float.current > val.value_float.max)
96 val.value_float.current = val.value_float.max;
97 m_message = std::string("\"")+getSelectedName()
98 +"\" = "+ftos(val.value_float.current);
101 m_message = std::string("\"")+getSelectedName()
102 +"\" has unknown value type";
104 setQuicktuneValue(getSelectedName(), val);
108 QuicktuneValue val = getQuicktuneValue(getSelectedName());
112 case QUICKTUNE_FLOAT:
113 val.value_float.current -= 0.05 * (val.value_float.max - val.value_float.min);
114 if(val.value_float.current < val.value_float.max)
115 val.value_float.current = val.value_float.max;
116 m_message = std::string("\"")+getSelectedName()
117 +"\" = "+ftos(val.value_float.current);
120 m_message = std::string("\"")+getSelectedName()
121 +"\" has unknown value type";
123 setQuicktuneValue(getSelectedName(), val);
127 void updateQuicktuneValue(const std::string &name, QuicktuneValue &val);
131 #define QUICKTUNE_FLOAT(var, min, max, name){\
133 qv.type = QUICKTUNE_FLOAT;\
134 qv.value_float.current = var;\
135 qv.value_float.min = min;\
136 qv.value_float.min = max;\
137 updateQuicktune(name, qv);\
138 var = qv.value_float.current;\
143 #define QUICKTUNE_FLOAT(var, min, max, name){}