package de.cdietze.playn_util;

import playn.core.Game;
import playn.core.Platform;
import tripleplay.anim.Animator;
import tripleplay.game.ScreenStack;
import tripleplay.ui.Element;
import tripleplay.ui.Layout;
import tripleplay.ui.SimpleStyles;
import tripleplay.ui.layout.AxisLayout;

public abstract class Screen extends ScreenStack.UIScreen {
    /**
     * An animator that's updated on every update(), thus can be used for game logic. This supplements {@link
     * tripleplay.ui.Interface#anim} which is updated on paint().
     */
    public final Animator updateAnim = new Animator();
    public final Platform plat;

    private final Game game;
    private final DialogKeeper dialogKeeper;

    public Screen(Game game) {
        super(game.plat);
        this.game = game;
        this.plat = game.plat;
        this.dialogKeeper = new DialogKeeper(this);
        update.connect(updateAnim.onPaint);
    }

    @Override
    public Game game() {
        return game;
    }

    /**
     * Returns a dialog which contains the supplied contents.
     */
    public DialogKeeper.Dialog createDialog(Element<?> dialog) {
        DialogKeeper.Dialog d = createDialog();
        d.root.add(dialog);
        return d;
    }

    /**
     * Returns a dialog with the supplied root layout.
     */
    public DialogKeeper.Dialog createDialog(Layout layout) {
        return dialogKeeper.new Dialog(this, iface.createRoot(layout, SimpleStyles.newSheet(plat.graphics()), layer));
    }

    /**
     * Returns a dialog with a vertical axis layout.
     */
    public DialogKeeper.Dialog createDialog() {
        return createDialog(AxisLayout.vertical());
    }
}

@@ -240,16 +240,49 @@
 Styles;%0A
+import tripleplay.ui.Stylesheet;%0A
 import t
@@ -1385,16 +1385,39 @@
 t layout
+, Stylesheet stylesheet
 ) %7B%0A    
@@ -1486,46 +1486,18 @@
 ut, 
-SimpleStyles.newSheet(plat.graphics())
+stylesheet
 , la
@@ -1676,16 +1676,56 @@
 rtical()
+, SimpleStyles.newSheet(plat.graphics())
 );%0A    %7D

Allow custom Stylesheet for Dialogs