TODO: NX PORT: Update for the Switch?
| 151 | |
| 152 | //TODO: NX PORT: Update for the Switch? |
| 153 | void GameModeManager_t::Tutorial_t::readFromFile() |
| 154 | { |
| 155 | levels.clear(); |
| 156 | if ( PHYSFS_getRealDir("/data/tutorial_strings.json") ) |
| 157 | { |
| 158 | std::string inputPath = PHYSFS_getRealDir("/data/tutorial_strings.json"); |
| 159 | inputPath.append("/data/tutorial_strings.json"); |
| 160 | |
| 161 | File* fp = FileIO::open(inputPath.c_str(), "rb"); |
| 162 | if ( !fp ) |
| 163 | { |
| 164 | printlog("[JSON]: Error: Could not locate json file %s", inputPath.c_str()); |
| 165 | return; |
| 166 | } |
| 167 | char buf[65536]; |
| 168 | int count = fp->read(buf, sizeof(buf[0]), sizeof(buf) - 1); |
| 169 | buf[count] = '\0'; |
| 170 | rapidjson::StringStream is(buf); |
| 171 | FileIO::close(fp); |
| 172 | |
| 173 | rapidjson::Document d; |
| 174 | d.ParseStream(is); |
| 175 | if ( !d.HasMember("version") || !d.HasMember("levels") ) |
| 176 | { |
| 177 | printlog("[JSON]: Error: No 'version' value in json file, or JSON syntax incorrect! %s", inputPath.c_str()); |
| 178 | return; |
| 179 | } |
| 180 | int version = d["version"].GetInt(); |
| 181 | |
| 182 | for ( rapidjson::Value::ConstMemberIterator level_itr = d["levels"].MemberBegin(); level_itr != d["levels"].MemberEnd(); ++level_itr ) |
| 183 | { |
| 184 | Tutorial_t::Level_t level; |
| 185 | level.filename = level_itr->name.GetString(); |
| 186 | level.title = level_itr->value["title"].GetString(); |
| 187 | level.description = level_itr->value["desc"].GetString(); |
| 188 | levels.push_back(level); |
| 189 | } |
| 190 | Menu.windowTitle = d["window_title"].GetString(); |
| 191 | Menu.defaultHoverText = d["default_hover_text"].GetString(); |
| 192 | printlog("[JSON]: Successfully read json file %s", inputPath.c_str()); |
| 193 | } |
| 194 | else |
| 195 | { |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | if ( PHYSFS_getRealDir(tutorialScoresFilename.c_str()) ) |
| 200 | { |
| 201 | std::string inputPath = PHYSFS_getRealDir(tutorialScoresFilename.c_str()); |
| 202 | inputPath.append(tutorialScoresFilename.c_str()); |
| 203 | |
| 204 | File* fp = FileIO::open(inputPath.c_str(), "rb"); |
| 205 | if ( !fp ) |
| 206 | { |
| 207 | printlog("[JSON]: Error: Could not locate json file %s", inputPath.c_str()); |
| 208 | return; |
| 209 | } |
| 210 | char buf[65536]; |
nothing calls this directly
no test coverage detected