use of delta.games.lotro.maps.data.MapBundle in project lotro-tools by dmorcellet.
the class MapsPageParser method parseMapLine.
private MapBundle parseMapLine(String data) {
MapBundle map = null;
// "angmar", { en: "Angmar", de: "Angmar", fr: "Angmar" }));
try {
int commaIndex = data.indexOf(',');
if (commaIndex != -1) {
String mapKey = data.substring(0, commaIndex);
if (mapKey.startsWith("\""))
mapKey = mapKey.substring(1);
if (mapKey.endsWith("\""))
mapKey = mapKey.substring(0, mapKey.length() - 1);
map = new MapBundle(mapKey);
String labels = data.substring(commaIndex + 1).trim();
if (labels.endsWith("));")) {
labels = labels.substring(0, labels.length() - 3).trim();
}
Labels labelsManager = map.getMap().getLabels();
ParsingUtils.parseLabels(labelsManager, labels);
}
} catch (Exception e) {
_logger.warn("Failed to parse map data [" + data + "]", e);
}
return map;
}
use of delta.games.lotro.maps.data.MapBundle in project lotro-tools by dmorcellet.
the class MarkersMerge method doIt.
/**
* Do it.
* @param mapsManager Maps manager to use.
*/
public void doIt(MapsManager mapsManager) {
List<MapBundle> mapBundles = mapsManager.getMaps();
for (MapBundle mapBundle : mapBundles) {
handleMap(mapBundle);
}
System.out.println("# different points:" + _currentId);
}
use of delta.games.lotro.maps.data.MapBundle in project lotro-tools by dmorcellet.
the class LinkCreationInterator method doLink.
private void doLink(MapBundle bundle, int x, int y) {
MapBundle currentMap = _canvas.getCurrentMap();
Map map = currentMap.getMap();
String target = bundle.getKey();
GeoPoint hotPoint = map.getGeoReference().pixel2geo(new Dimension(x, y));
MapLink link = new MapLink(target, hotPoint);
map.addLink(link);
_manager.saveMap(map.getKey());
_canvas.repaint();
}
use of delta.games.lotro.maps.data.MapBundle in project lotro-tools by dmorcellet.
the class MainLinkEditor method main.
/**
* Main method for this test.
* @param args Not used.
*/
public static void main(String[] args) {
File rootDir = new File("../lotro-maps-db");
final MapsManager mapsManager = new MapsManager(rootDir);
mapsManager.load();
Filter<Marker> filter = new Filter<Marker>() {
public boolean accept(Marker item) {
return false;
}
};
MapBundle bundle = mapsManager.getMapByKey("breeland");
MapCanvas canvas = new MapCanvas(mapsManager);
final NavigationManager navigationManager = new NavigationManager(canvas);
NavigationListener listener = new NavigationListener() {
public void mapChangeRequest(String key) {
navigationManager.setMap(mapsManager.getMapByKey(key).getMap());
}
};
navigationManager.setNavigationListener(listener);
/*LinkCreationInterator interactor=*/
new LinkCreationInterator(mapsManager, canvas);
canvas.setFilter(filter);
String key = bundle.getKey();
canvas.setMap(key);
navigationManager.setMap(bundle.getMap());
JFrame f = new JFrame();
String title = bundle.getLabel();
f.setTitle(title);
f.getContentPane().add(canvas);
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
use of delta.games.lotro.maps.data.MapBundle 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