Skip to content

Commit 844ba39

Browse files
Slight cleanup
1 parent f4c96e8 commit 844ba39

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

src/main/java/io/github/ultimateboomer/resolutioncontrol/ResolutionControlMod.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import org.jetbrains.annotations.Nullable;
2222
import org.lwjgl.glfw.GLFW;
2323

24-
import java.util.ArrayList;
25-
import java.util.List;
24+
import java.util.HashSet;
2625
import java.util.Objects;
26+
import java.util.Set;
2727

2828
public class ResolutionControlMod implements ModInitializer {
2929
public static final String MOD_ID = "resolutioncontrol";
@@ -61,7 +61,7 @@ public static ResolutionControlMod getInstance() {
6161
@Nullable
6262
private Framebuffer clientFramebuffer;
6363

64-
private List<Framebuffer> minecraftFramebuffers;
64+
private Set<Framebuffer> minecraftFramebuffers;
6565

6666
private Class<? extends SettingsScreen> lastSettingsScreen = MainSettingsScreen.class;
6767

@@ -134,6 +134,8 @@ private void saveScreenshot(Framebuffer fb) {
134134

135135
public void setShouldScale(boolean shouldScale) {
136136
if (shouldScale == this.shouldScale) return;
137+
138+
if (getScaleFactor() == 1) return;
137139

138140
Window window = getWindow();
139141
if (framebuffer == null) {
@@ -146,11 +148,11 @@ public void setShouldScale(boolean shouldScale) {
146148
);
147149
calculateSize();
148150
}
149-
151+
150152
this.shouldScale = shouldScale;
151-
153+
152154
client.getProfiler().swap(shouldScale ? "startScaling" : "finishScaling");
153-
155+
154156
// swap out framebuffers as needed
155157
if (shouldScale) {
156158
clientFramebuffer = client.getFramebuffer();
@@ -197,15 +199,15 @@ public void setShouldScale(boolean shouldScale) {
197199
);
198200
}
199201
}
200-
202+
201203
client.getProfiler().swap("level");
202204
}
203205

204206
public void initMinecraftFramebuffers() {
205207
if (minecraftFramebuffers != null) {
206208
minecraftFramebuffers.clear();
207209
} else {
208-
minecraftFramebuffers = new ArrayList<>();
210+
minecraftFramebuffers = new HashSet<>();
209211
}
210212

211213
minecraftFramebuffers.add(client.worldRenderer.getEntityOutlinesFramebuffer());
@@ -352,19 +354,19 @@ public void onResolutionChanged() {
352354
if (getWindow() == null)
353355
return;
354356

355-
LOGGER.debug("Size changed to {}x{} {}x{} {}x{}",
357+
LOGGER.info("Size changed to {}x{} {}x{} {}x{}",
356358
getWindow().getFramebufferWidth(), getWindow().getFramebufferHeight(),
357359
getWindow().getWidth(), getWindow().getHeight(),
358360
getWindow().getScaledWidth(), getWindow().getScaledHeight());
359361

360-
if (getWindow().getScaledHeight() == lastWidth
361-
|| getWindow().getScaledHeight() == lastHeight)
362-
{
362+
// if (getWindow().getScaledHeight() == lastWidth
363+
// || getWindow().getScaledHeight() == lastHeight)
364+
// {
363365
updateFramebufferSize();
364366

365367
lastWidth = getWindow().getScaledHeight();
366368
lastHeight = getWindow().getScaledHeight();
367-
}
369+
// }
368370

369371

370372
}
@@ -374,7 +376,8 @@ public void updateFramebufferSize() {
374376
return;
375377

376378
resize(framebuffer);
377-
resizeMinecraftFramebuffers();
379+
resize(client.worldRenderer.getEntityOutlinesFramebuffer());
380+
// resizeMinecraftFramebuffers();
378381

379382
calculateSize();
380383
}

src/main/java/io/github/ultimateboomer/resolutioncontrol/mixin/WindowMixin.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import net.minecraft.client.util.Window;
55
import net.minecraft.util.math.MathHelper;
66
import org.spongepowered.asm.mixin.Mixin;
7-
import org.spongepowered.asm.mixin.Unique;
87
import org.spongepowered.asm.mixin.injection.At;
98
import org.spongepowered.asm.mixin.injection.Inject;
109
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -14,17 +13,17 @@
1413
public abstract class WindowMixin {
1514
@Inject(at = @At("RETURN"), method = "getFramebufferWidth", cancellable = true)
1615
private void getFramebufferWidth(CallbackInfoReturnable<Integer> ci) {
17-
if (getRCMod().isScreenshotting()) {
18-
ci.setReturnValue(getRCMod().getScreenshotWidth());
16+
if (ResolutionControlMod.getInstance().isScreenshotting()) {
17+
ci.setReturnValue(ResolutionControlMod.getInstance().getScreenshotWidth());
1918
} else {
2019
ci.setReturnValue(scale(ci.getReturnValueI()));
2120
}
2221
}
2322

2423
@Inject(at = @At("RETURN"), method = "getFramebufferHeight", cancellable = true)
2524
private void getFramebufferHeight(CallbackInfoReturnable<Integer> ci) {
26-
if (getRCMod().isScreenshotting()) {
27-
ci.setReturnValue(getRCMod().getScreenshotHeight());
25+
if (ResolutionControlMod.getInstance().isScreenshotting()) {
26+
ci.setReturnValue(ResolutionControlMod.getInstance().getScreenshotHeight());
2827
} else {
2928
ci.setReturnValue(scale(ci.getReturnValueI()));
3029
}
@@ -49,9 +48,4 @@ private void onFramebufferSizeChanged(CallbackInfo ci) {
4948
private void onUpdateFramebufferSize(CallbackInfo ci) {
5049
ResolutionControlMod.getInstance().onResolutionChanged();
5150
}
52-
53-
@Unique
54-
private ResolutionControlMod getRCMod() {
55-
return ResolutionControlMod.getInstance();
56-
}
5751
}

0 commit comments

Comments
 (0)