reVeno/Source/Veno/Core/Config.cpp

103 lines
1.8 KiB
C++
Raw Normal View History

2020-04-03 13:23:19 +02:00
//
// Created by versustune on 01.03.20.
//
#include "Config.h"
#include "../Fonts/Fonts.h"
2020-04-03 13:23:19 +02:00
std::shared_ptr<Config> Config::m_instance = nullptr;
2020-04-03 13:23:19 +02:00
Config::Config ()
{
// i want to load the m_config file here...
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
}
void Config::saveAll ()
{
if (m_config != nullptr)
{
m_config->saveIfNeeded ();
2020-04-03 13:23:19 +02:00
}
}
int Config::getCurrentLook ()
{
if (m_currentLook > 1)
{
m_currentLook = 0;
2020-04-03 13:23:19 +02:00
}
return m_currentLook;
2020-04-03 13:23:19 +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";
m_config = std::make_unique<PropertiesFile> (options);
2020-04-03 13:23:19 +02:00
}
std::shared_ptr<Theme> Config::getCurrentTheme ()
{
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)
{
if (m_theme)
{
m_theme->setColour (index, colour);
2020-04-03 13:23:19 +02:00
}
}
Config::~Config ()
{
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)
{
m_editors[name] = editor;
2020-04-03 13:23:19 +02:00
}
void Config::removeEditor (const std::string& name)
{
m_editors.erase (name);
if (m_editors.empty ())
{
VenoFonts::destroyAll ();
m_instance = nullptr;
2020-04-03 13:23:19 +02:00
}
}
//for LCD :P let's be a bit funny xD
int Config::getEditorCount ()
{
return m_editors.size ();
}
std::shared_ptr<Config> Config::getInstance ()
{
2020-06-13 10:56:20 +02:00
if (m_instance == nullptr)
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
{
2020-06-13 10:56:20 +02:00
return m_fps;
}