void MapParser::parseMap(Model::Map& map, Utility::ProgressIndicator* indicator) { Model::Entity* entity = NULL; if (indicator != NULL) indicator->reset(static_cast<int>(m_size)); try { while ((entity = parseEntity(map.worldBounds(), indicator)) != NULL) map.addEntity(*entity); } catch (MapParserException e) { m_console.error(e.what()); } if (indicator != NULL) indicator->update(static_cast<int>(m_size)); if (!m_staleBrushes.empty()) { StringStream stream; stream << "Found brushes with invalid or missing geometry at lines "; for (size_t i = 0; i < m_staleBrushes.size(); i++) { const Model::Brush* brush = m_staleBrushes[i]; stream << brush->fileLine(); if (i < m_staleBrushes.size() - 1) stream << ", "; } m_console.warn(stream.str()); } }
void DisplayVisuaLayerStrategy::display() { Model::Map * map = mapView->getMap(); for(int i=0;i<map->getSize().width();i++) { for(int j=0;j<map->getSize().height();j++) { BlocMap * bloc = map->getBloc(i,j); mapView->blitTile(i,j,bloc,LOW); mapView->blitTile(i,j,bloc,HIGH); } } }
void MapParser::parseMap(Model::Map& map, Utility::ProgressIndicator* indicator) { Model::Entity* entity = NULL; if (indicator != NULL) indicator->reset(static_cast<int>(m_size)); try { while ((entity = parseEntity(map.worldBounds(), indicator)) != NULL) map.addEntity(*entity); } catch (MapParserException e) { m_console.error(e.what()); } if (indicator != NULL) indicator->update(static_cast<int>(m_size)); }
void MapWriter::writeToStream(const Model::Map& map, std::ostream& stream) { assert(stream.good()); stream.unsetf(std::ios::floatfield); const Model::EntityList& entities = map.entities(); for (unsigned int i = 0; i < entities.size(); i++) writeEntity(*entities[i], stream); }
void MapWriter::writeToFileAtPath(Model::Map& map, const String& path, bool overwrite) { FileManager fileManager; if (fileManager.exists(path) && !overwrite) return; const String directoryPath = fileManager.deleteLastPathComponent(path); if (!fileManager.exists(directoryPath)) fileManager.makeDirectory(directoryPath); FILE* stream = fopen(path.c_str(), "w"); if (stream == NULL) throw IOException::openError(path); // std::fstream stream(path.c_str(), std::ios::out | std::ios::trunc); size_t lineNumber = 1; const Model::EntityList& entities = map.entities(); for (unsigned int i = 0; i < entities.size(); i++) lineNumber += writeEntity(*entities[i], lineNumber, stream); fclose(stream); }