2020-04-03 13:23:19 +02:00
|
|
|
//
|
|
|
|
// Created by versustune on 01.03.20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Config.h"
|
|
|
|
|
2020-06-08 21:27:17 +02:00
|
|
|
std::shared_ptr<Config> Config::m_instance = nullptr;
|
2020-04-03 13:23:19 +02:00
|
|
|
|
|
|
|
Config::Config() {
|
2020-06-08 21:27:17 +02:00
|
|
|
// i want to load the m_config file here...
|
2020-04-03 13:23:19 +02:00
|
|
|
initConfig();
|
|
|
|
|
2020-06-08 21:27:17 +02:00
|
|
|
m_theme = std::make_shared<Theme>(m_config);
|
|
|
|
m_theme->init();
|
2020-06-13 10:56:20 +02:00
|
|
|
m_fps = m_config->getIntValue("waveform_fps", 60);
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Config::saveAll() {
|
2020-06-08 21:27:17 +02:00
|
|
|
if (m_config != nullptr) {
|
|
|
|
m_config->saveIfNeeded();
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Config::getCurrentLook() {
|
2020-06-08 21:27:17 +02:00
|
|
|
if (m_currentLook > 1) {
|
|
|
|
m_currentLook = 0;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
2020-06-08 21:27:17 +02:00
|
|
|
return m_currentLook;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Config::initConfig() {
|
|
|
|
PropertiesFile::Options options;
|
2020-06-13 10:56:20 +02:00
|
|
|
options.applicationName = "config";
|
2020-04-03 13:23:19 +02:00
|
|
|
options.folderName = "veno";
|
|
|
|
options.filenameSuffix = "xml";
|
2020-06-08 21:27:17 +02:00
|
|
|
m_config = std::make_unique<PropertiesFile>(options);
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Theme> Config::getCurrentTheme() {
|
2020-06-08 21:27:17 +02:00
|
|
|
return m_theme;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
double Config::getScale() {
|
2020-06-13 10:56:20 +02:00
|
|
|
return 1;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Config::setColourForIndex(Colour *colour, ThemeColour index) {
|
2020-06-08 21:27:17 +02:00
|
|
|
if (m_theme) {
|
|
|
|
m_theme->setColour(index, colour);
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Config::~Config() {
|
2020-06-08 21:27:17 +02:00
|
|
|
m_config->save();
|
|
|
|
m_theme.reset();
|
|
|
|
m_config.reset();
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//LEAK DETECTOR FIX!
|
|
|
|
void Config::registerEditor(AudioProcessorEditor *editor, const std::string &name) {
|
2020-06-08 21:27:17 +02:00
|
|
|
m_editors[name] = editor;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Config::removeEditor(const std::string &name) {
|
2020-06-08 21:27:17 +02:00
|
|
|
m_editors.erase(name);
|
|
|
|
if (m_editors.empty()) {
|
|
|
|
m_instance = nullptr;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//for LCD :P let's be a bit funny xD
|
|
|
|
int Config::getEditorCount() {
|
2020-06-08 21:27:17 +02:00
|
|
|
return m_editors.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<Config> Config::getInstance() {
|
2020-06-13 10:56:20 +02:00
|
|
|
if (m_instance == nullptr)
|
2020-06-08 21:27:17 +02:00
|
|
|
m_instance = std::make_shared<Config>();
|
|
|
|
return m_instance;
|
2020-04-03 13:23:19 +02:00
|
|
|
}
|
2020-06-13 10:56:20 +02:00
|
|
|
|
|
|
|
int Config::getFps() const {
|
|
|
|
return m_fps;
|
|
|
|
}
|