Add DemoMode for auditioning samples without storing them in database.

This commit is contained in:
apoorv569
2022-03-05 14:35:19 +05:30
parent 3db1e5858e
commit 023874a9be
12 changed files with 224 additions and 14 deletions
+58
View File
@@ -69,6 +69,11 @@ namespace SampleHive {
m_Emitter << YAML::Key << "ShowStatusBar" << YAML::Value << true;
m_Emitter << YAML::EndMap << YAML::Newline;
m_Emitter << YAML::Newline << YAML::Key << "General";
m_Emitter << YAML::BeginMap;
m_Emitter << YAML::Key << "DemoMode" << YAML::Value << false;
m_Emitter << YAML::EndMap << YAML::Newline;
m_Emitter << YAML::Newline << YAML::Key << "Media";
m_Emitter << YAML::BeginMap;
m_Emitter << YAML::Key << "Autoplay" << YAML::Value << false;
@@ -806,4 +811,57 @@ namespace SampleHive {
return show_extension;
}
void cSerializer::SerializeDemoMode(bool showDemoMode)
{
YAML::Emitter out;
try
{
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
if (auto general = config["General"])
{
general["DemoMode"] = showDemoMode;
out << config;
std::ofstream ofstrm(static_cast<std::string>(CONFIG_FILEPATH));
ofstrm << out.c_str();
}
else
{
SH_LOG_ERROR("Error! Cannot store show demo mode value.");
}
}
catch (const YAML::ParserException& ex)
{
SH_LOG_ERROR(ex.what());
}
}
bool cSerializer::DeserializeDemoMode() const
{
bool show_demo_mode = false;
try
{
YAML::Node config = YAML::LoadFile(static_cast<std::string>(CONFIG_FILEPATH));
if (auto general = config["General"])
{
show_demo_mode = general["DemoMode"].as<bool>();
}
else
{
SH_LOG_ERROR("Error! Cannot fetch show demo mode value.");
}
}
catch (const YAML::ParserException& ex)
{
SH_LOG_ERROR(ex.what());
}
return show_demo_mode;
}
}
+4
View File
@@ -109,6 +109,10 @@ namespace SampleHive {
void SerializeShowFileExtension(bool showExtension);
bool DeserializeShowFileExtension() const;
// Demo mode
void SerializeDemoMode(bool showDemoMode);
bool DeserializeDemoMode() const;
private:
// -------------------------------------------------------------------
YAML::Emitter m_Emitter;
+5 -2
View File
@@ -88,8 +88,11 @@ namespace SampleHive {
//Check All Files At Once
wxArrayString sorted_files;
sorted_files = db.CheckDuplicates(files);
files = sorted_files;
if (!serializer.DeserializeDemoMode())
{
sorted_files = db.CheckDuplicates(files);
files = sorted_files;
}
if (files.size() < 1)
{