use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class FovableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final Xml root = new Xml("test");
root.add(FovableConfig.exports(1));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(1, FovableConfig.imports(new Xml(media)));
assertEquals(1, FovableConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class Factory method createSetup.
/**
* Create a setup from its media.
*
* @param media The media reference.
* @param standard <code>true</code> for standard setup, <code>false</code> else.
* @return The setup instance.
*/
@SuppressWarnings("unchecked")
private Setup createSetup(Media media, boolean standard) {
final Configurer configurer = new Configurer(media);
try {
final FeaturableConfig config = FeaturableConfig.imports(configurer);
final String setup = config.getSetupName();
final Class<? extends Setup> setupClass;
if (standard) {
setupClass = Setup.class;
} else if (setup.isEmpty()) {
final Class<?> clazz = classLoader.loadClass(config.getClassName());
final Constructor<?> constructor = UtilReflection.getCompatibleConstructorParent(clazz, new Class<?>[] { Services.class, Setup.class });
setupClass = (Class<? extends Setup>) constructor.getParameterTypes()[SETUP_INDEX];
} else {
setupClass = (Class<? extends Setup>) classLoader.loadClass(config.getSetupName());
}
return UtilReflection.create(setupClass, new Class<?>[] { Media.class }, media);
} catch (final ClassNotFoundException exception) {
throw new LionEngineException(exception, media, ERROR_SETUP_CLASS);
} catch (final NoSuchMethodException exception) {
throw new LionEngineException(exception, ERROR_CONSTRUCTOR_MISSING + media.getPath());
}
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class ActionsConfigTest method testCancelOnRef.
/**
* Test cancel flag is not used on child reference.
*/
@Test
void testCancelOnRef() {
final ActionRef ref = new ActionRef("ref", true, new ArrayList<ActionRef>());
final Collection<ActionRef> refs = Arrays.asList(new ActionRef("test", false, Arrays.asList(ref)));
final Xml root = new Xml("test");
root.add(ActionsConfig.exports(refs));
final Media media = Medias.create("producer.xml");
root.save(media);
assertNotEquals(refs, ActionsConfig.imports(new Xml(media), null));
assertNotEquals(refs, ActionsConfig.imports(new Configurer(media), null));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class ExtractableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final ExtractableConfig config = new ExtractableConfig("gold", 1);
final Xml root = new Xml("test");
root.add(ExtractableConfig.exports(config));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(config, ExtractableConfig.imports(new Xml(media)));
assertEquals(config, ExtractableConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Configurer in project lionengine by b3dgs.
the class ExtractorConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final ExtractorConfig config = new ExtractorConfig(1.0, 2.0, 3);
final Xml root = new Xml("test");
root.add(ExtractorConfig.exports(config));
final Media media = Medias.create("Object.xml");
root.save(media);
assertEquals(config, ExtractorConfig.imports(new Xml(media)));
assertEquals(config, ExtractorConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
Aggregations