-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.hpp
More file actions
29 lines (28 loc) · 847 Bytes
/
button.hpp
File metadata and controls
29 lines (28 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once
#include "item.hpp"
class Button : public Item {
public:
Button(string name, bool& value) : Item(name), m_bValue(value) {};
bool getValue() { return m_bValue; };
void display(string extraText) override {
printf("%i. %s [%s] %s\n", this->getItemNum(), this->getDisplayName().c_str(), m_bValue ? "X" : "", extraText.c_str());
}
virtual void execute() override {
m_bValue = !m_bValue;
}
virtual string createConfig() override {
return this->getName() + ":" + to_string(m_bValue) + "\n";
}
virtual void loadConfig(string data) override {
istringstream d(data);
string line;
while (getline(d, line)) {
vector<string> sData = Util::splitString(line, ':');
if (this->getName() == sData.at(0)) {
m_bValue = sData.at(1) == "1" ? true : false;
}
}
}
private:
bool &m_bValue;
};