Skip to content

Commit

Permalink
Merge pull request #56 from FIUS/feature/reset-zoom
Browse files Browse the repository at this point in the history
Add reset for zoom on task switch
  • Loading branch information
buehlefs authored Oct 2, 2019
2 parents d3c25b8 + 0fdf713 commit d07c9ef
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ public void setTaskSelectorListener(TaskSelectorListener listener) {
@Override
public void selectedTaskChange(String element) {
if (!element.equals(this.currentTaskName)) {
this.gameWindow.getPlayfieldDrawer().resetZoomAndPan();
this.switchTask(element);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public interface PlayfieldDrawer {
* The number of the current tick
*/
void draw(long tickCount);

/**
* Reset Zoom and Pan applied by the user to the default values.
*/
public void resetZoomAndPan();
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ public void draw(long tickCount) {
this.repaintManager.setDoubleBufferingEnabled(bufferEnabled);
}

@Override
public void resetZoomAndPan() {
this.scale = 1.0;
this.offsetX = SwingPlayfieldDrawer.CELL_SIZE;
this.offsetY = SwingPlayfieldDrawer.CELL_SIZE;
}

@Override
public Dimension getPreferredSize() {
return new Dimension(800, 600);
Expand Down

0 comments on commit d07c9ef

Please sign in to comment.