Search in sources :

Example 16 with WPObject

use of org.pepsoft.worldpainter.objects.WPObject in project WorldPainter by Captain-Chaos.

the class Bo2ObjectTube method load.

/**
 * Create a new <code>Bo2ObjectTube</code> with a specific name from a list
 * of specific custom object files.
 *
 * @param name The name of the new <code>Bo2ObjectTube</code>.
 * @param files The list of files containing the objects to load.
 * @return A new <code>Bo2ObjectTube</code> containing the custom objects
 *     from the specified file(s).
 * @throws IOException If there was an I/O error reading one of the files.
 */
public static Bo2ObjectTube load(String name, Collection<File> files) throws IOException {
    if (files.isEmpty()) {
        throw new IllegalArgumentException("Cannot create an object tube with no objects");
    }
    List<WPObject> objects = new ArrayList<>(files.size());
    CustomObjectManager customObjectManager = CustomObjectManager.getInstance();
    for (File file : files) {
        objects.add(customObjectManager.loadObject(file));
    }
    return new Bo2ObjectTube(name, objects);
}
Also used : CustomObjectManager(org.pepsoft.worldpainter.plugins.CustomObjectManager) WPObject(org.pepsoft.worldpainter.objects.WPObject) ArrayList(java.util.ArrayList) File(java.io.File)

Example 17 with WPObject

use of org.pepsoft.worldpainter.objects.WPObject in project WorldPainter by Captain-Chaos.

the class EditObjectAttributes method editOffset.

private void editOffset() {
    if (objects.size() > 1) {
        return;
    }
    WPObject object = objects.iterator().next();
    Point3i offset = offsets.get(object);
    OffsetEditor dialog = new OffsetEditor(this, (offset != null) ? offset : new Point3i(), object, colourScheme);
    dialog.setVisible(true);
    if (!dialog.isCancelled()) {
        offset = dialog.getOffset();
        offsets.put(object, offset);
        String offsetStr = "<html><u>" + offset.x + ", " + offset.y + ", " + offset.z + "</u></html>";
        labelOffset.setText(offsetStr);
    }
}
Also used : Point3i(javax.vecmath.Point3i) WPObject(org.pepsoft.worldpainter.objects.WPObject)

Aggregations

WPObject (org.pepsoft.worldpainter.objects.WPObject)17 File (java.io.File)4 Point3i (javax.vecmath.Point3i)3 CustomObjectManager (org.pepsoft.worldpainter.plugins.CustomObjectManager)3 IOException (java.io.IOException)2 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 MirroredObject (org.pepsoft.worldpainter.objects.MirroredObject)2 RotatedObject (org.pepsoft.worldpainter.objects.RotatedObject)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 CertificateException (java.security.cert.CertificateException)1 CertificateFactory (java.security.cert.CertificateFactory)1 X509Certificate (java.security.cert.X509Certificate)1 Dimension (org.pepsoft.worldpainter.Dimension)1 Fixup (org.pepsoft.worldpainter.exporting.Fixup)1 Bo2Layer (org.pepsoft.worldpainter.layers.Bo2Layer)1 Bo2ObjectProvider (org.pepsoft.worldpainter.layers.bo2.Bo2ObjectProvider)1