Versatile Java game engine with pluggable backends (this was used in Rogue, I think)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gamecore/src/mightypork/gamecore/core/events/ShutdownRequest.java

42 lines
893 B

10 years ago
package mightypork.gamecore.core.events;
10 years ago
import mightypork.gamecore.core.App;
10 years ago
import mightypork.utils.eventbus.BusEvent;
import mightypork.utils.eventbus.EventBus;
import mightypork.utils.logging.Log;
/**
* Shutdown event.<br>
* This event is dispatched when the <code>App.shutdown()</code> method is
* called. If no client consumes it, the shutdown will immediately follow.<br>
* This is a way to allow clients to abort the shutdown (ie. ask to save game).
*
10 years ago
* @author Ondřej Hruška (MightyPork)
*/
public class ShutdownRequest extends BusEvent<ShutdownRequestListener> {
10 years ago
10 years ago
@Override
protected void handleBy(ShutdownRequestListener handler)
10 years ago
{
handler.onShutdownRequested(this);
10 years ago
}
10 years ago
10 years ago
@Override
public void onDispatchComplete(EventBus bus)
{
if (!isConsumed()) {
Log.i("Shutting down...");
10 years ago
App.shutdown();
10 years ago
10 years ago
} else {
Log.i("Shutdown aborted.");
}
}
10 years ago
10 years ago
}