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