use of com.b3dgs.lionengine.game.feature.Actionable in project lionengine by b3dgs.
the class Hud method createMenu.
/**
* Create menu from action and add to active menus.
*
* @param action The action used.
* @return The created menu.
*/
private Actionable createMenu(ActionRef action) {
Actionable menu = menus.get(action);
if (menu == null) {
final Featurable featurable = factory.create(Medias.create(PATH.split(action.getPath())));
handler.add(featurable);
menu = featurable.getFeature(Actionable.class);
menus.put(action, menu);
}
menu.setEnabled(true);
active.add(menu);
return menu;
}
use of com.b3dgs.lionengine.game.feature.Actionable in project lionengine by b3dgs.
the class HudTest method testListenerCancel.
/**
* Test cancel with listener.
*/
@Test
void testListenerCancel() {
final AtomicBoolean canceled = new AtomicBoolean();
final HudListener listener = new HudListener() {
@Override
public void notifyCreated(List<Selectable> selection, Actionable actionable) {
// Nothing to do
}
@Override
public void notifyCanceled() {
canceled.set(true);
}
};
final Hud hud = new Hud(services, setup);
hud.addListener(listener);
final AtomicBoolean cancel = new AtomicBoolean();
hud.setCancelShortcut(cancel::get);
hud.getFeature(Refreshable.class).update(1.0);
assertFalse(canceled.get());
cancel.set(true);
hud.getFeature(Refreshable.class).update(1.0);
assertTrue(canceled.get());
assertEquals(0, hud.getActive().size());
hud.removeListener(listener);
}
Aggregations