void HGAssets::loadAssets() { lo("::loadAssets") << "loading local profiles" << endl; loadLocalProfiles(); for(const auto& packPath : getScan<Mode::Single, Type::Folder>("Packs/")) { const auto& packPathStr(packPath.getStr()); string packName{packPathStr.substr(6, packPathStr.size() - 7)}, packLua; for(const auto& p : getScan<Mode::Recurse, Type::File, Pick::ByExt>(packPath, ".lua")) packLua.append(getFileContents(p)); ssvuj::Obj packRoot{getFromFile(packPath + "/pack.json")}; ssvu::getEmplaceUptrMap<PackData>(packDatas, packName, packName, getExtr<string>(packRoot, "name"), getExtr<float>(packRoot, "priority")); } for(auto& p : packDatas) { const auto& pd(p.second); string packId{pd->id}, packPath{"Packs/" + packId + "/"}; packIds.emplace_back(packId); packPaths.emplace_back(packPath); if(!levelsOnly) { lo("::loadAssets") << "loading " << packId << " music\n"; loadMusic(packPath); } if(!levelsOnly) { lo("::loadAssets") << "loading " << packId << " music data\n"; loadMusicData(packPath); } lo("::loadAssets") << "loading " << packId << " style data\n"; loadStyleData(packPath); lo("::loadAssets") << "loading " << packId << " level data\n"; loadLevelData(packPath); if(!levelsOnly) { lo("::loadAssets") << "loading " << packId << " custom sounds\n"; loadCustomSounds(packId, packPath); } lo().flush(); } }
void loadAssets() { log("loading profiles", "LoadAssets"); loadProfiles(); for(string packPath : getScan<Mode::Single, Type::Folder>("Packs/")) { string packName{packPath.substr(6, packPath.length() - 6)}; string packLua{""}; for(const auto& path : getScan<Mode::Recurse, Type::File, Pick::ByExt>(packPath, ".lua")) packLua.append(getFileContents(path)); string packHash{Online::getMD5Hash(packLua + HG_SKEY1 + HG_SKEY2 + HG_SKEY3)}; Json::Value packRoot{getRootFromFile(packPath + "/pack.json")}; PackData packData(packName, packRoot["name"].asString(), packRoot["priority"].asFloat(), packHash); packDataMap.insert(make_pair(packName, packData)); } vector<PackData> packDatasToQuery; for(pair<string, PackData> packDataPair : packDataMap) packDatasToQuery.push_back(packDataPair.second); sort(begin(packDatasToQuery), end(packDatasToQuery), [](PackData a, PackData b) { return a.getPriority() < b.getPriority(); }); for(PackData packData : packDatasToQuery) { string packName{packData.getId()}, packPath{"Packs/" + packName + "/"}; packPaths.push_back("Packs/" + packName + "/"); log("loading " + packName + " music", "LoadAssets"); loadMusic(packPath); log("loading " + packName + " music data", "LoadAssets"); loadMusicData(packPath); log("loading " + packName + " style data", "LoadAssets"); loadStyleData(packPath); log("loading " + packName + " level data", "LoadAssets"); loadLevelData(packPath); log("loading " + packName + " events", "LoadAssets"); loadEvents(packPath); log("loading " + packName + " custom sounds", "LoadAssets"); loadCustomSounds(packName, packPath); } }
void loadAssets() { log("loading fonts"); loadFonts(); log("loading sounds"); loadSounds(); log("loading music"); loadMusic(); log("loading music data"); loadMusicData(); log("loading style data"); loadStyleData(); log("loading level data"); loadLevelData(); log("loading scores"); loadScores(); }