diff --git a/src/games/stendhal/client/GameScreen.java b/src/games/stendhal/client/GameScreen.java index 29719dbd2f..02fe255291 100644 --- a/src/games/stendhal/client/GameScreen.java +++ b/src/games/stendhal/client/GameScreen.java @@ -178,6 +178,11 @@ public final class GameScreen extends JComponent implements IGameScreen, DropTar private AchievementBoxFactory achievementBoxFactory; + /** + * Callback for instructions to execute when scene drawing is complete for a cycle. + */ + public SceneCompleteRunnable onSceneComplete; + /** the singleton instance. */ private static GameScreen screen; @@ -591,6 +596,10 @@ public void paintComponent(final Graphics g) { drawText(g2d); drawEmojis(g2d); + if (onSceneComplete != null) { + onSceneComplete.run(g2d, 0, 0); + } + paintOffLineIfNeeded(g2d); // Ask window manager to not skip frame drawing @@ -1049,4 +1058,12 @@ private RPObject findSpell(KeyEvent e) { public boolean canAccept(IEntity entity) { return (entity instanceof Item) || (entity instanceof Corpse); } + + + /** + * Class for executing instructions after scene is complete in a draw cycle. + */ + public static abstract class SceneCompleteRunnable { + public abstract void run(Graphics2D ctx, int offsetX, int offsetY); + } }