Skip to content

Commit

Permalink
Add optional callable to execute instructions after scene...
Browse files Browse the repository at this point in the history
...drawing is complete
  • Loading branch information
AntumDeluge committed Jun 22, 2024
1 parent 94f4068 commit 3f2e132
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/games/stendhal/client/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 3f2e132

Please sign in to comment.