Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
quicktune_shortcutter.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "quicktune.h"
8
10{
11private:
12 std::vector<std::string> m_names;
14 std::string m_message;
15public:
16 bool hasMessage() const
17 {
18 return !m_message.empty();
19 }
20
21 std::string getMessage()
22 {
23 std::string s = m_message;
24 m_message.clear();
25 if (!s.empty())
26 return std::string("[quicktune] ") + s;
27 return "";
28 }
29 std::string getSelectedName()
30 {
31 if(m_selected_i < m_names.size())
32 return m_names[m_selected_i];
33 return "(nothing)";
34 }
35 void next()
36 {
38 if(m_selected_i < m_names.size()-1)
40 else
41 m_selected_i = 0;
42 m_message = std::string("Selected \"")+getSelectedName()+"\"";
43 }
44 void prev()
45 {
47 if(m_selected_i > 0)
49 else
50 m_selected_i = m_names.size()-1;
51 m_message = std::string("Selected \"")+getSelectedName()+"\"";
52 }
53 void inc()
54 {
56 val.relativeAdd(0.05);
57 m_message = std::string("\"")+getSelectedName()
58 +"\" = "+val.getString();
60 }
61 void dec()
62 {
64 val.relativeAdd(-0.05);
65 m_message = std::string("\"")+getSelectedName()
66 +"\" = "+val.getString();
68 }
69};
Definition quicktune_shortcutter.h:10
std::vector< std::string > m_names
Definition quicktune_shortcutter.h:12
void prev()
Definition quicktune_shortcutter.h:44
void inc()
Definition quicktune_shortcutter.h:53
u32 m_selected_i
Definition quicktune_shortcutter.h:13
void dec()
Definition quicktune_shortcutter.h:61
std::string m_message
Definition quicktune_shortcutter.h:14
std::string getMessage()
Definition quicktune_shortcutter.h:21
void next()
Definition quicktune_shortcutter.h:35
std::string getSelectedName()
Definition quicktune_shortcutter.h:29
bool hasMessage() const
Definition quicktune_shortcutter.h:16
QuicktuneValue getQuicktuneValue(const std::string &name)
Definition quicktune.cpp:44
void setQuicktuneValue(const std::string &name, const QuicktuneValue &val)
Definition quicktune.cpp:56
const std::vector< std::string > & getQuicktuneNames()
Definition quicktune.cpp:39
Definition quicktune.h:45
void relativeAdd(float amount)
Definition quicktune.cpp:20
std::string getString()
Definition quicktune.cpp:9