//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011-2014, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.demo;

import playn.core.Game;
import playn.core.PlayN;
import playn.core.util.Clock;

import tripleplay.game.ScreenStack;

public class TripleDemo extends Game.Default
{
    /** Args from the Java bootstrap class. */
    public static String[] mainArgs = {};

    public static final int UPDATE_RATE = 25;

    public TripleDemo () {
        super(UPDATE_RATE);
    }

    @Override public void init () {
        _screens.push(new DemoMenuScreen(_screens));
    }

    @Override public void update (int delta) {
        _clock.update(delta);
        _screens.update(delta);
    }

    @Override public void paint (float alpha) {
        _clock.paint(alpha);
        _screens.paint(_clock);
    }

    protected final Clock.Source _clock = new Clock.Source(UPDATE_RATE);

    protected final ScreenStack _screens = new ScreenStack() {
        @Override protected void handleError (RuntimeException error) {
            PlayN.log().warn("Screen failure", error);
        }
        @Override protected Transition defaultPushTransition () {
            return slide();
        }
        @Override protected Transition defaultPopTransition () {
            return slide().right();
        }
    };
}

@@ -218,16 +218,42 @@
 .demo;%0A%0A
+import java.util.Arrays;%0A%0A
 import p
@@ -323,17 +323,16 @@
 .Clock;%0A
-%0A
 import t
@@ -694,16 +694,217 @@
 reens));
+%0A%0A        // propagate events so that things like buttons inside a scroller work%0A        if (!Arrays.asList(mainArgs).contains(%22--no-propagate%22)) %7B%0A            PlayN.setPropagateEvents(true);%0A        %7D
 %0A    %7D%0A%0A

Make fancy things like scrolling menus work in the demo.