Skip to content

Commit c636420

Browse files
committed
fix: fix exit fullscreen scaling issue
1 parent 7969ea8 commit c636420

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/main/java/tbooop/view/InputManagerImpl.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ public void handleInput(final Optional<Keybinds> keybind) {
8585
case SHOOT_LEFT -> sendCommand(new ShootCommand(CardinalDirection.LEFT));
8686
case SHOOT_RIGHT -> sendCommand(new ShootCommand(CardinalDirection.RIGHT));
8787
case FULLSCREEN -> view.getStage().setFullScreen(!view.getStage().isFullScreen());
88-
case EXIT_FULLSCREEN -> resizeWindow(false);
88+
case EXIT_FULLSCREEN -> {
89+
System.out.println("Exiting fullscreen");
90+
view.getStage().setWidth(view.getStage().getWidth() / 2);
91+
resizeWindow(false);
92+
}
8993
case ZOOM_IN -> resizeWindow(true);
9094
case ZOOM_OUT -> resizeWindow(false);
9195
default -> {
@@ -103,8 +107,7 @@ private void resizeWindow(final boolean scaleUp) {
103107
if (newWidth < RoomBounds.WIDTH) {
104108
return;
105109
}
106-
if (newWidth / view.getStageAspectRatio()
107-
> Screen.getPrimary().getVisualBounds().getHeight()) {
110+
if (newWidth / view.getStageAspectRatio() > Screen.getPrimary().getVisualBounds().getHeight()) {
108111
view.getStage().setFullScreen(true);
109112
return;
110113
}

src/main/java/tbooop/view/ViewImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,6 @@ private synchronized Point2d worldToScreenPos(final Point2d worldPos) {
182182
@Override
183183
public void showDeathScreen() {
184184
super.getStage().setScene(new DeathScreen().getDeathScene(getStage().getWidth(), getStage().getHeight()));
185-
}
185+
}
186186

187187
}

src/main/java/tbooop/view/api/Keybinds.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public KeyCode getKeyCode() {
9797
public static boolean isGui(final Keybinds keybind) {
9898
return keybind == Keybinds.FULLSCREEN
9999
|| keybind == Keybinds.ZOOM_IN
100-
|| keybind == Keybinds.ZOOM_OUT;
100+
|| keybind == Keybinds.ZOOM_OUT
101+
|| keybind == Keybinds.EXIT_FULLSCREEN;
101102
}
102103

103104
/**

0 commit comments

Comments
 (0)