use of delta.games.lotro.maps.data.io.xml.CategoriesXMLWriter in project lotro-tools by dmorcellet.
the class MainDynMapLoader method doIt.
private void doIt() {
DynMapSiteInterface dynMap = new DynMapSiteInterface();
// Categories
File localizationFile = dynMap.download(DynMapConstants.LOCALIZATION_PAGE, "localization.js");
List<String> localizationPage = TextUtils.readAsLines(localizationFile);
CategoriesParser categoriesParser = new CategoriesParser();
CategoriesManager categories = categoriesParser.parse(localizationPage);
// Maps
File mapsFile = dynMap.download(DynMapConstants.MAP_PAGE, "map.js");
List<String> mapsPage = TextUtils.readAsLines(mapsFile);
MapsPageParser mapsParser = new MapsPageParser();
List<MapBundle> maps = mapsParser.parse(mapsPage, categories);
// Load all map data
for (MapBundle map : maps) {
String key = map.getKey();
File mapDir = new File(new File(_outDir, "maps"), key);
// JS
String jsUrl = DynMapConstants.BASE_URL + "/data/" + key + ".js";
File js = dynMap.download(jsUrl, key + ".js");
loadMapData(map, js, categories);
// Inspect
MarkersManager markers = map.getData();
for (Category category : categories.getAllSortedByCode()) {
List<Marker> markersList = markers.getByCategory(category);
System.out.println(category);
for (Marker marker : markersList) {
System.out.println("\t" + marker);
}
}
// Map images
String[] locales = { "en", "de", "fr" };
for (String locale : locales) {
String mapUrl = DynMapConstants.BASE_URL + "/images/maps/" + locale + '/' + key + ".jpg";
File mapImageFile = new File(mapDir, "map_" + locale + ".jpg");
dynMap.download(mapUrl, mapImageFile);
}
System.out.println(map.getMap());
// Write file
MapXMLWriter writer = new MapXMLWriter();
File toFile = new File(mapDir, "markers.xml");
writer.writeMarkersFile(toFile, map, EncodingNames.UTF_8);
}
// Write categories file
{
CategoriesXMLWriter writer = new CategoriesXMLWriter();
File toFile = new File(_outDir, "categories.xml");
writer.write(toFile, categories, EncodingNames.UTF_8);
}
File imagesDir = new File(_outDir, "images");
for (Category category : categories.getAllSortedByCode()) {
String key = category.getIcon();
String iconUrl = DynMapConstants.BASE_URL + "/images/" + key + ".gif";
File toFile = new File(imagesDir, key + ".gif");
dynMap.download(iconUrl, toFile);
System.out.println(category);
}
}
Aggregations