Search in sources :

Example 1 with MapBundle

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;
}
Also used : Labels(delta.games.lotro.maps.data.Labels) MapBundle(delta.games.lotro.maps.data.MapBundle)

Example 2 with MapBundle

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);
}
Also used : MapBundle(delta.games.lotro.maps.data.MapBundle)

Example 3 with MapBundle

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();
}
Also used : GeoPoint(delta.games.lotro.maps.data.GeoPoint) MapLink(delta.games.lotro.maps.data.MapLink) MapBundle(delta.games.lotro.maps.data.MapBundle) Dimension(java.awt.Dimension) Map(delta.games.lotro.maps.data.Map)

Example 4 with MapBundle

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);
}
Also used : MapsManager(delta.games.lotro.maps.data.MapsManager) NavigationManager(delta.games.lotro.maps.ui.NavigationManager) MapCanvas(delta.games.lotro.maps.ui.MapCanvas) Filter(delta.common.utils.collections.filters.Filter) JFrame(javax.swing.JFrame) NavigationListener(delta.games.lotro.maps.ui.NavigationListener) Marker(delta.games.lotro.maps.data.Marker) MapBundle(delta.games.lotro.maps.data.MapBundle) File(java.io.File)

Example 5 with MapBundle

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);
    }
}
Also used : Category(delta.games.lotro.maps.data.Category) CategoriesXMLWriter(delta.games.lotro.maps.data.io.xml.CategoriesXMLWriter) Marker(delta.games.lotro.maps.data.Marker) MapXMLWriter(delta.games.lotro.maps.data.io.xml.MapXMLWriter) CategoriesManager(delta.games.lotro.maps.data.CategoriesManager) MapBundle(delta.games.lotro.maps.data.MapBundle) File(java.io.File) MarkersManager(delta.games.lotro.maps.data.MarkersManager)

Aggregations

MapBundle (delta.games.lotro.maps.data.MapBundle)8 Category (delta.games.lotro.maps.data.Category)3 Marker (delta.games.lotro.maps.data.Marker)3 CategoriesManager (delta.games.lotro.maps.data.CategoriesManager)2 MarkersManager (delta.games.lotro.maps.data.MarkersManager)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 ComboBoxController (delta.common.ui.swing.combobox.ComboBoxController)1 Filter (delta.common.utils.collections.filters.Filter)1 IntegerHolder (delta.common.utils.misc.IntegerHolder)1 GeoPoint (delta.games.lotro.maps.data.GeoPoint)1 Labels (delta.games.lotro.maps.data.Labels)1 Map (delta.games.lotro.maps.data.Map)1 MapLink (delta.games.lotro.maps.data.MapLink)1 MapsManager (delta.games.lotro.maps.data.MapsManager)1 CategoriesXMLWriter (delta.games.lotro.maps.data.io.xml.CategoriesXMLWriter)1 MapXMLWriter (delta.games.lotro.maps.data.io.xml.MapXMLWriter)1 MapCanvas (delta.games.lotro.maps.ui.MapCanvas)1 NavigationListener (delta.games.lotro.maps.ui.NavigationListener)1 NavigationManager (delta.games.lotro.maps.ui.NavigationManager)1