beginning of layered screen

v5stable
Ondřej Hruška 11 years ago
parent b7f0057eaa
commit 24071a7d59
  1. 1
      src/mightypork/rogue/App.java
  2. 2
      src/mightypork/rogue/display/LayeredScreen.java
  3. 61
      src/mightypork/rogue/display/rendering/ScreenLayer.java

@ -52,6 +52,7 @@ public class App implements Destroyable, AppAccess {
*/
public static void main(String[] args)
{
Thread.setDefaultUncaughtExceptionHandler(new CrashHandler());
inst = new App();

@ -54,12 +54,14 @@ public abstract class LayeredScreen extends Screen {
protected void addLayer(ScreenLayer layer)
{
this.layers.add(layer);
addChildSubscriber(layer);
}
protected void removeLayer(ScreenLayer layer)
{
this.layers.remove(layer);
addChildSubscriber(layer);
}
}

@ -1,17 +1,56 @@
package mightypork.rogue.display.rendering;
import java.util.Collection;
import java.util.LinkedHashSet;
import mightypork.rogue.AppAdapter;
import mightypork.rogue.bus.UpdateReceiver;
import mightypork.rogue.display.Screen;
import mightypork.rogue.input.KeyBinder;
import mightypork.rogue.input.KeyBindingPool;
import mightypork.rogue.input.KeyStroke;
import mightypork.utils.patterns.subscription.clients.DelegatingClient;
import mightypork.utils.time.Updateable;
public abstract class ScreenLayer extends UpdateReceiver implements Renderable {
/**
* Screen layer<br>
* Plugged into a screen as a child bus subscriber, receiving update and render
* calls directly from the screen.
*
* @author MightyPork
*/
public abstract class ScreenLayer extends AppAdapter implements KeyBinder, DelegatingClient, Renderable, Updateable {
private Screen screen;
private KeyBindingPool keybindings;
private Collection<Object> layerChildClients = new LinkedHashSet<Object>();
public ScreenLayer(Screen screen) {
super(screen);
super(screen); // screen as AppAccess
this.screen = screen;
layerChildClients.add(keybindings = new KeyBindingPool());
}
@Override
public final void bindKeyStroke(KeyStroke stroke, Runnable task)
{
keybindings.bindKeyStroke(stroke, task);
}
@Override
public final void unbindKeyStroke(KeyStroke stroke)
{
keybindings.unbindKeyStroke(stroke);
}
@ -22,8 +61,24 @@ public abstract class ScreenLayer extends UpdateReceiver implements Renderable {
@Override
public abstract void update(double delta);
protected Screen screen() {
protected Screen screen()
{
return screen;
}
@Override
public Collection<Object> getChildClients()
{
return layerChildClients;
}
@Override
public final boolean doesDelegate()
{
return true;
}
}

Loading…
Cancel
Save