MCPcopy Create free account
hub / github.com/EasyRPG/Player / RequestAndAddMap

Method RequestAndAddMap

src/translation.cpp:239–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239void Translation::RequestAndAddMap(int map_id) {
240 if (current_language.lang_dir.empty()) {
241 return;
242 }
243
244 std::stringstream ss;
245 ss << "Map" << std::setfill('0') << std::setw(4) << map_id << ".po";
246 std::string map_name = ss.str();
247
248 if (maps.find(Utils::LowerCase(map_name)) != maps.end()) {
249 // Already loaded
250 return;
251 }
252
253 FileRequestAsync* request = AsyncHandler::RequestFile(Tr::GetCurrentTranslationFilesystem().GetFullPath(), map_name);
254 request->SetImportantFile(true);
255 map_request = request->Bind([this, map_name](FileRequestResult*) {
256 std::unique_ptr<Dictionary> dict = std::make_unique<Dictionary>();
257 auto is = Tr::GetCurrentTranslationFilesystem().OpenInputStream(map_name);
258 if (is) {
259 ParsePoFile(std::move(is), *dict);
260 maps[Utils::LowerCase(map_name)] = std::move(dict);
261 Output::Debug("Loaded {} map .po file ({} map files loaded)", map_name, maps.size());
262 }
263 });
264 request->Start();
265}
266
267bool Translation::ParseLanguageFiles(std::string_view lang_id)
268{

Callers 1

RequestMapMethod · 0.80

Calls 8

GetFullPathMethod · 0.80
SetImportantFileMethod · 0.80
OpenInputStreamMethod · 0.80
emptyMethod · 0.45
endMethod · 0.45
BindMethod · 0.45
sizeMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected