good except 1 mysterious NPE in SimplePainter on poll.
This commit is contained in:
@@ -11,6 +11,7 @@ import mightypork.gamecore.audio.SoundSystem;
|
||||
import mightypork.gamecore.control.bus.EventBus;
|
||||
import mightypork.gamecore.control.bus.events.*;
|
||||
import mightypork.gamecore.control.interf.Destroyable;
|
||||
import mightypork.gamecore.control.timing.Pollable;
|
||||
import mightypork.gamecore.control.timing.Updateable;
|
||||
import mightypork.gamecore.gui.screens.ScreenRegistry;
|
||||
import mightypork.gamecore.input.InputSystem;
|
||||
@@ -255,6 +256,7 @@ public abstract class BaseApp implements AppAccess, UncaughtExceptionHandler {
|
||||
// framework events
|
||||
bus.addChannel(DestroyEvent.class, Destroyable.class);
|
||||
bus.addChannel(UpdateEvent.class, Updateable.class);
|
||||
bus.addChannel(LayoutChangeEvent.class, Pollable.class);
|
||||
|
||||
// input events
|
||||
bus.addChannel(ScreenChangeEvent.class, ScreenChangeEvent.Listener.class);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package mightypork.gamecore.gui.components;
|
||||
|
||||
|
||||
import mightypork.utils.annotations.DefaultImpl;
|
||||
import mightypork.utils.math.constraints.rect.Rect;
|
||||
import mightypork.utils.math.constraints.rect.RectAdapter;
|
||||
import mightypork.utils.math.constraints.rect.RectBound;
|
||||
import mightypork.utils.math.constraints.rect.RectBoundAdapter;
|
||||
import mightypork.utils.math.constraints.rect.RectCache;
|
||||
|
||||
|
||||
/**
|
||||
@@ -11,10 +14,9 @@ import mightypork.utils.math.constraints.rect.RectBoundAdapter;
|
||||
*
|
||||
* @author MightyPork
|
||||
*/
|
||||
public abstract class SimplePainter extends RectBoundAdapter implements PluggableRenderable {
|
||||
public abstract class SimplePainter extends RectAdapter implements PluggableRenderable {
|
||||
|
||||
@Override
|
||||
public abstract void render();
|
||||
private RectCache source;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -27,6 +29,41 @@ public abstract class SimplePainter extends RectBoundAdapter implements Pluggabl
|
||||
@Override
|
||||
public void setRect(RectBound rect)
|
||||
{
|
||||
super.setRect(rect);
|
||||
System.out.println("SP set rect");
|
||||
this.source = new RectBoundAdapter(rect).cached();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Rect getSource()
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Poll bounds
|
||||
*/
|
||||
@Override
|
||||
public final void poll()
|
||||
{
|
||||
System.out.println("SP poll, source: "+source);
|
||||
source.poll();
|
||||
super.poll();
|
||||
|
||||
onPoll();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public abstract void render();
|
||||
|
||||
|
||||
/**
|
||||
* Called after painter was polled; contained constraints can now poll too.
|
||||
*/
|
||||
@DefaultImpl
|
||||
public void onPoll()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,5 +141,4 @@ public class TextPainter extends SimplePainter {
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package mightypork.gamecore.gui.screens;
|
||||
|
||||
import mightypork.gamecore.control.AppAccess;
|
||||
import mightypork.gamecore.control.AppSubModule;
|
||||
import mightypork.gamecore.control.bus.events.LayoutChangeEvent;
|
||||
import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
|
||||
import mightypork.gamecore.gui.components.Renderable;
|
||||
import mightypork.gamecore.input.KeyBinder;
|
||||
@@ -99,6 +100,9 @@ public abstract class Screen extends AppSubModule implements Renderable, KeyBind
|
||||
|
||||
onSizeChanged(event.getScreenSize());
|
||||
|
||||
// poll constraints
|
||||
getEventBus().sendDirectToChildren(this, new LayoutChangeEvent());
|
||||
|
||||
needSetupViewport = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user