MCPcopy Create free account
hub / github.com/TheWaveWarden/odin2 / loadDataFromFile

Method loadDataFromFile

Source/ConfigFileManager.cpp:38–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void ConfigFileManager::loadDataFromFile() {
39 String path_absolute = CONFIG_FILE_PATH;
40 File configuration_file = File(path_absolute);
41
42 if (configuration_file.existsAsFile()) {
43 auto config_xml = XmlDocument::parse(configuration_file);
44
45 //parse() returns nullptr for any problem
46 if (config_xml.get()) {
47 if (config_xml->hasTagName(XML_ATTRIBUTE_ODIN_CONFIG)) {
48 for (auto *child : config_xml->getChildIterator()) {
49 if (child->hasTagName(XML_ATTRIBUTE_BIG_GUI)) {
50 m_big_gui = child->getBoolAttribute("data");
51 } else if (child->hasTagName(XML_ATTRIBUTE_SPLINE_AD1)) {
52 m_spline_ad_1_seen = child->getBoolAttribute("data");
53 } else if (child->hasTagName(XML_ATTRIBUTE_SPLINE_AD2)) {
54 m_spline_ad_2_seen = child->getBoolAttribute("data");
55 } else if (child->hasTagName(XML_ATTRIBUTE_SHOW_TOOLTIP)) {
56 m_show_tooltip = child->getBoolAttribute("data");
57 } else if (child->hasTagName(XML_ATTRIBUTE_TUNING_DIR)) {
58 m_tuning_dir = child->getStringAttribute("data");
59 } else if (child->hasTagName(XML_ATTRIBUTE_SOUNDBANK_DIR)) {
60 m_soundbank_dir = child->getStringAttribute("data");
61 } else if (child->hasTagName(XML_ATTRIBUTE_PATCH_DIR)) {
62 m_patch_dir = child->getStringAttribute("data");
63 } else if (child->hasTagName(XML_ATTRIBUTE_GUI_SCALE)) {
64 m_gui_scale = std::stoi(child->getStringAttribute("data").toStdString());
65 } else if (child->hasTagName(XML_ATTRIBUTE_GUI_OPEN)) {
66 m_num_gui_opens = std::stoi(child->getStringAttribute("data").toStdString());
67 }
68 }
69 }
70 } else {
71 DBG("ConfigFile exists, but could not be parsed!");
72 }
73 } else {
74 DBG("ConfigFile does not exist!");
75 }
76}
77
78void ConfigFileManager::saveDataToFile() {
79 std::unique_ptr<XmlElement> config_xml = std::make_unique<XmlElement>(XML_ATTRIBUTE_ODIN_CONFIG);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected