Skip to content

Commit

Permalink
Merge pull request #126 from MUKSC/feature/keep-zoom-offset
Browse files Browse the repository at this point in the history
Add `keepZoom` and `keepOffset` option
  • Loading branch information
sisby-folk committed Jun 3, 2024
2 parents 9bfa690 + 58231fb commit d01fcf9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public enum FallbackHandling {
@Comment("The background is slightly less stylish, but more tiles are shown at once")
public Boolean fullscreen = true;

@Comment("Whether to keep scale after closing the map")
public Boolean keepZoom = false;

@Comment("Whether to keep offset after closing the map")
public Boolean keepOffset = false;

@Comment("How to depict player death locations.")
public GraveStyle graveStyle = GraveStyle.EUPHEMISMS;

Expand Down
18 changes: 12 additions & 6 deletions src/main/java/folk/sisby/antique_atlas/gui/AtlasScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ public class AtlasScreen extends Component {

private boolean isDragging = false;

private double mapOffsetX;
private double mapOffsetY;
private static double mapOffsetX;
private static double mapOffsetY;

private int tilePixels = 16;
private int tileChunks = 1;
private static int tilePixels = 16;
private static int tileChunks = 1;
private int mapScale;

public AtlasScreen() {
Expand All @@ -163,7 +163,6 @@ public AtlasScreen() {
mapScale = getMapScale();

playerBookmark = new BookmarkButton(Text.translatable("gui.antique_atlas.followPlayer"), AntiqueAtlas.id("textures/gui/player.png"), DyeColor.GRAY, null, 7, 8, false);
playerBookmark.setSelected(true);
addChild(playerBookmark).offsetGuiCoords(bookWidth - 10, bookHeight - MAP_BORDER_HEIGHT - BookmarkButton.HEIGHT - 10);
playerBookmark.addListener(b -> {
selectedButton = playerBookmark;
Expand Down Expand Up @@ -251,7 +250,13 @@ public AtlasScreen prepareToOpen() {

this.player = MinecraftClient.getInstance().player;
updateAtlasData();
setMapPosition(player.getBlockX(), player.getBlockZ());
if (!AntiqueAtlas.CONFIG.keepOffset) {
playerBookmark.setSelected(true);
setMapPosition(player.getBlockX(), player.getBlockZ());
}
if (!AntiqueAtlas.CONFIG.keepZoom) {
resetZoom();
}

return this;
}
Expand All @@ -262,6 +267,7 @@ public void init() {

setGuiCoords((this.width - bookWidth) / 2, (this.height - bookHeight) / 2);

updateScaleBookmark();
updateBookmarkerList();
}

Expand Down

0 comments on commit d01fcf9

Please sign in to comment.