Compare commits
No commits in common. "068af590456f49ee2d6732b73d84fa24176f8927" and "7daed8f7d1ff135092d3314174b275c898c8b8f5" have entirely different histories.
068af59045
...
7daed8f7d1
@ -0,0 +1,10 @@
|
|||||||
|
package net.deechael.concentration.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.main.Main;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
|
@Mixin(Main.class)
|
||||||
|
public class MainMixin {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -89,11 +89,7 @@ public abstract class VideoSettingsScreenMixin extends OptionsSubScreen {
|
|||||||
@Unique
|
@Unique
|
||||||
private static OptionInstance<Boolean> concentration$wrapperFullscreen(Options options) {
|
private static OptionInstance<Boolean> concentration$wrapperFullscreen(Options options) {
|
||||||
// Don't put a constant to the second parameter, or else whatever fullscreen you are, when you open video settings page, the value shown is always the same
|
// Don't put a constant to the second parameter, or else whatever fullscreen you are, when you open video settings page, the value shown is always the same
|
||||||
return OptionInstance.createBoolean(
|
return OptionInstance.createBoolean("options.fullscreen", options.fullscreen().get(), (value) -> Concentration.toggleFullScreenMode(options, value));
|
||||||
"options.fullscreen",
|
|
||||||
options.fullscreen().get(),
|
|
||||||
(value) -> Concentration.toggleFullScreenMode(options, value)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"mixins": [],
|
"mixins": [],
|
||||||
"client": [
|
"client": [
|
||||||
"KeyboardHandlerMixin",
|
"KeyboardHandlerMixin",
|
||||||
|
"MainMixin",
|
||||||
"VideoSettingsScreenMixin",
|
"VideoSettingsScreenMixin",
|
||||||
"accessor.WindowAccessor"
|
"accessor.WindowAccessor"
|
||||||
],
|
],
|
||||||
|
@ -19,8 +19,8 @@ dependencies {
|
|||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||||
|
|
||||||
modImplementation "maven.modrinth:modmenu:11.0.0"
|
modImplementation "maven.modrinth:modmenu:11.0.0"
|
||||||
|
modImplementation "maven.modrinth:sodium:mc1.21-0.5.11"
|
||||||
modImplementation "maven.modrinth:sodium:mc1.21-0.6.0-beta.2-fabric"
|
modImplementation "maven.modrinth:sodium:mc1.21-0.6.0-beta.2-fabric"
|
||||||
modImplementation "maven.modrinth:sodium-extra:mc1.21.1-0.6.0-beta.3+fabric"
|
|
||||||
modImplementation "maven.modrinth:vulkanmod:0.4.9-fabric,1.21"
|
modImplementation "maven.modrinth:vulkanmod:0.4.9-fabric,1.21"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ public class ConcentrationFabricCaching {
|
|||||||
|
|
||||||
public static boolean cachedSize = false;
|
public static boolean cachedSize = false;
|
||||||
public static boolean cachedPos = false;
|
public static boolean cachedPos = false;
|
||||||
public static boolean cacheSizeLock = true;
|
public static boolean cacheSizeLock = false;
|
||||||
|
|
||||||
public static int cachedX = 0;
|
public static int cachedX = 0;
|
||||||
public static int cachedY = 0;
|
public static int cachedY = 0;
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
package net.deechael.concentration.fabric.compat;
|
|
||||||
|
|
||||||
import me.flashyreese.mods.sodiumextra.client.SodiumExtraClientMod;
|
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
|
|
||||||
public class SodiumExtraCompat {
|
|
||||||
|
|
||||||
public static boolean checkMacReduceResolution() {
|
|
||||||
if (!FabricLoader.getInstance().isModLoaded("sodium-extra"))
|
|
||||||
return false;
|
|
||||||
String os = System.getProperty("os.name").toLowerCase();
|
|
||||||
if (!(os.contains("mac") || os.contains("darwin")))
|
|
||||||
return false;
|
|
||||||
return checkMacReduceResolution0();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean checkMacReduceResolution0() {
|
|
||||||
return SodiumExtraClientMod.options().extraSettings.reduceResolutionOnMac;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -28,13 +28,12 @@ public class GLFWMixin {
|
|||||||
|
|
||||||
@Inject(method = "glfwSetWindowMonitor", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "glfwSetWindowMonitor", at = @At("HEAD"), cancellable = true)
|
||||||
private static void inject$glfwSetWindowMonitor(long window, long monitor, int xpos, int ypos, int width, int height, int refreshRate, CallbackInfo ci) {
|
private static void inject$glfwSetWindowMonitor(long window, long monitor, int xpos, int ypos, int width, int height, int refreshRate, CallbackInfo ci) {
|
||||||
Window windowInstance = Minecraft.getInstance().getWindow();
|
|
||||||
if (windowInstance == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("================= [Concentration Start] =================");
|
ConcentrationConstants.LOGGER.info("================= [Concentration Start] =================");
|
||||||
ConcentrationConstants.LOGGER.info("Trying to modify window monitor");
|
ConcentrationConstants.LOGGER.info("Trying to modify window monitor");
|
||||||
|
|
||||||
|
Window windowInstance = Minecraft.getInstance().getWindow();
|
||||||
|
if (windowInstance == null)
|
||||||
|
return;
|
||||||
WindowAccessor accessor = (WindowAccessor) (Object) windowInstance;
|
WindowAccessor accessor = (WindowAccessor) (Object) windowInstance;
|
||||||
|
|
||||||
if (windowInstance.isFullscreen())
|
if (windowInstance.isFullscreen())
|
||||||
@ -95,7 +94,7 @@ public class GLFWMixin {
|
|||||||
finalHeight = config.height + (config.height == height ? 1 : 0);
|
finalHeight = config.height + (config.height == height ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
finalX = monitorInstance.getX();
|
finalX = monitorInstance.getX();
|
||||||
finalY = monitorInstance.getY();
|
finalY = monitorInstance.getY() - 1;
|
||||||
finalWidth = width;
|
finalWidth = width;
|
||||||
finalHeight = height + 1;
|
finalHeight = height + 1;
|
||||||
}
|
}
|
||||||
@ -133,10 +132,6 @@ public class GLFWMixin {
|
|||||||
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor != 0L) {
|
|
||||||
ConcentrationFabricCaching.lastMonitor = monitor;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
||||||
|
@ -27,23 +27,24 @@ public class OptionsMixin {
|
|||||||
Option<?>[] newOptions = new Option<?>[6];
|
Option<?>[] newOptions = new Option<?>[6];
|
||||||
newOptions[0] = options[0];
|
newOptions[0] = options[0];
|
||||||
newOptions[1] = options[1];
|
newOptions[1] = options[1];
|
||||||
newOptions[2] = options[2];
|
newOptions[2] = new CyclingOption<>(
|
||||||
newOptions[3] = new CyclingOption<>(
|
|
||||||
Component.translatable("concentration.option.fullscreen_mode"),
|
Component.translatable("concentration.option.fullscreen_mode"),
|
||||||
FullscreenMode.values(),
|
FullscreenMode.values(),
|
||||||
value -> {
|
value -> {
|
||||||
ConcentrationConfigFabric.getInstance().fullscreen = value;
|
ConcentrationConfigFabric.getInstance().fullscreen = value;
|
||||||
ConcentrationConfigFabric.getInstance().save();
|
ConcentrationConfigFabric.getInstance().save();
|
||||||
if (minecraftOptions.fullscreen().get()) {
|
if (minecraftOptions.fullscreen().get()) {
|
||||||
|
// If fullscreen turns on, re-toggle to changing the fullscreen mode instantly
|
||||||
Concentration.toggleFullScreenMode(minecraftOptions, true);
|
Concentration.toggleFullScreenMode(minecraftOptions, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
() -> ConcentrationConfigFabric.getInstance().fullscreen
|
() -> ConcentrationConfigFabric.getInstance().fullscreen
|
||||||
).setTranslator(fullscreenMode -> Component.translatable(fullscreenMode.getKey()));
|
).setTranslator(fullscreenMode -> Component.translatable(fullscreenMode.getKey()));
|
||||||
|
newOptions[3] = options[3];
|
||||||
newOptions[4] = options[4];
|
newOptions[4] = options[4];
|
||||||
newOptions[5] = options[5];
|
newOptions[5] = options[5];
|
||||||
|
|
||||||
Option<Boolean> fullscreenOption = (Option<Boolean>) newOptions[2];
|
Option<Boolean> fullscreenOption = (Option<Boolean>) newOptions[3];
|
||||||
fullscreenOption.setOnApply(value -> {
|
fullscreenOption.setOnApply(value -> {
|
||||||
Concentration.toggleFullScreenMode(minecraftOptions, value);
|
Concentration.toggleFullScreenMode(minecraftOptions, value);
|
||||||
});
|
});
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package net.deechael.concentration.fabric.mixin;
|
package net.deechael.concentration.fabric.mixin;
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.*;
|
import com.mojang.blaze3d.platform.Monitor;
|
||||||
|
import com.mojang.blaze3d.platform.ScreenManager;
|
||||||
|
import com.mojang.blaze3d.platform.VideoMode;
|
||||||
|
import com.mojang.blaze3d.platform.Window;
|
||||||
import net.deechael.concentration.ConcentrationConstants;
|
import net.deechael.concentration.ConcentrationConstants;
|
||||||
import net.deechael.concentration.FullscreenMode;
|
import net.deechael.concentration.FullscreenMode;
|
||||||
import net.deechael.concentration.config.Config;
|
import net.deechael.concentration.config.Config;
|
||||||
import net.deechael.concentration.config.ConfigProvider;
|
|
||||||
import net.deechael.concentration.fabric.ConcentrationFabricCaching;
|
import net.deechael.concentration.fabric.ConcentrationFabricCaching;
|
||||||
import net.deechael.concentration.fabric.compat.SodiumExtraCompat;
|
|
||||||
import net.deechael.concentration.fabric.config.ConcentrationConfigFabric;
|
import net.deechael.concentration.fabric.config.ConcentrationConfigFabric;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
import org.lwjgl.glfw.GLFWNativeWin32;
|
import org.lwjgl.glfw.GLFWNativeWin32;
|
||||||
@ -47,20 +48,12 @@ public abstract class WindowMixin {
|
|||||||
@Final
|
@Final
|
||||||
private long window;
|
private long window;
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("RETURN"))
|
@Shadow
|
||||||
private void inject$init(WindowEventHandler eventHandler, ScreenManager screenManager, DisplayData displayData, String preferredFullscreenVideoMode, String title, CallbackInfo ci) {
|
public abstract boolean isFullscreen();
|
||||||
ConcentrationConstants.LOGGER.info(" =============================================");
|
|
||||||
String osName = System.getProperty("os.name").toLowerCase();
|
@Shadow public abstract int getScreenWidth();
|
||||||
if (osName.contains("windows")) {
|
|
||||||
ConcentrationConstants.LOGGER.info(" == System: Windows ==");
|
@Shadow public abstract int getScreenHeight();
|
||||||
} else if (osName.contains("darwin") || osName.contains("mac")) {
|
|
||||||
ConcentrationConstants.LOGGER.info(" == System: macOS ==");
|
|
||||||
} else {
|
|
||||||
ConcentrationConstants.LOGGER.info(" == System: Linux ==");
|
|
||||||
}
|
|
||||||
// ConcentrationConstants.LOGGER.info(" == ==");
|
|
||||||
ConcentrationConstants.LOGGER.info(" =============================================");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "onMove", at = @At("HEAD"))
|
@Inject(method = "onMove", at = @At("HEAD"))
|
||||||
private void inject$onMove$head(long window, int x, int y, CallbackInfo ci) {
|
private void inject$onMove$head(long window, int x, int y, CallbackInfo ci) {
|
||||||
@ -93,7 +86,6 @@ public abstract class WindowMixin {
|
|||||||
|
|
||||||
Monitor monitorInstance = this.screenManager.getMonitor(monitor);
|
Monitor monitorInstance = this.screenManager.getMonitor(monitor);
|
||||||
ConcentrationConstants.LOGGER.info("Current fullscreen monitor is {}", monitor);
|
ConcentrationConstants.LOGGER.info("Current fullscreen monitor is {}", monitor);
|
||||||
ConcentrationConstants.LOGGER.info("Current fullscreen mode is {}", ConfigProvider.INSTANCE.ensureLoaded().getFullscreenMode());
|
|
||||||
|
|
||||||
if (monitor != 0L) {
|
if (monitor != 0L) {
|
||||||
VideoMode currentMode = monitorInstance.getCurrentMode();
|
VideoMode currentMode = monitorInstance.getCurrentMode();
|
||||||
@ -145,20 +137,17 @@ public abstract class WindowMixin {
|
|||||||
finalHeight = config.height + (config.height == height ? 1 : 0);
|
finalHeight = config.height + (config.height == height ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
finalX = monitorInstance.getX();
|
finalX = monitorInstance.getX();
|
||||||
finalY = monitorInstance.getY();
|
finalY = monitorInstance.getY() - 1;
|
||||||
finalWidth = ignored$width;
|
finalWidth = ignored$width;
|
||||||
finalHeight = ignored$height + 1;
|
finalHeight = ignored$height + 1;
|
||||||
}
|
}
|
||||||
if (SodiumExtraCompat.checkMacReduceResolution()) {
|
|
||||||
ConcentrationConstants.LOGGER.info("On macOS and reduce resolution in Sodium Extra enabled, reduce the resolution");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.x = finalX;
|
this.x = finalX;
|
||||||
this.y = finalY;
|
this.y = finalY;
|
||||||
this.width = finalWidth;
|
this.width = finalWidth;
|
||||||
this.height = finalHeight;
|
this.height = finalHeight;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ConcentrationConstants.LOGGER.info("Trying to switch to windowed mode");
|
ConcentrationConstants.LOGGER.info("Trying to switch to windowed mode");
|
||||||
finalMonitor = 0L;
|
finalMonitor = 0L;
|
||||||
@ -184,10 +173,6 @@ public abstract class WindowMixin {
|
|||||||
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor != 0L) {
|
|
||||||
ConcentrationFabricCaching.lastMonitor = monitor;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
||||||
@ -217,7 +202,7 @@ public abstract class WindowMixin {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE);
|
GLFW.glfwSetWindowAttrib(window, GLFW.GLFW_DECORATED, GLFW.GLFW_FALSE);
|
||||||
GLFW.glfwSetWindowAttrib(this.window, 0x20006, 1);
|
GLFW.glfwSetWindowAttrib(this.window, 0x20006, 0);
|
||||||
if (System.getProperty("os.name").contains("Windows")) {
|
if (System.getProperty("os.name").contains("Windows")) {
|
||||||
long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window);
|
long hWnd = GLFWNativeWin32.glfwGetWin32Window(this.window);
|
||||||
if (hWnd != 0) {
|
if (hWnd != 0) {
|
||||||
|
@ -48,6 +48,9 @@ public abstract class WindowMixin {
|
|||||||
@Final
|
@Final
|
||||||
private long window;
|
private long window;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract boolean isFullscreen();
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private long concentration$lastMonitor = -1;
|
private long concentration$lastMonitor = -1;
|
||||||
|
|
||||||
@ -56,7 +59,7 @@ public abstract class WindowMixin {
|
|||||||
@Unique
|
@Unique
|
||||||
private boolean concentration$cachedPos = false;
|
private boolean concentration$cachedPos = false;
|
||||||
@Unique
|
@Unique
|
||||||
private boolean concentration$cacheSizeLock = true;
|
private boolean concentration$cacheSizeLock = false;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private int concentration$cachedX = 0;
|
private int concentration$cachedX = 0;
|
||||||
@ -154,7 +157,7 @@ public abstract class WindowMixin {
|
|||||||
finalHeight = configHeight + (configHeight == height ? 1 : 0);
|
finalHeight = configHeight + (configHeight == height ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
finalX = monitorInstance.getX();
|
finalX = monitorInstance.getX();
|
||||||
finalY = monitorInstance.getY();
|
finalY = monitorInstance.getY() - 1;
|
||||||
finalWidth = width;
|
finalWidth = width;
|
||||||
finalHeight = height + 1;
|
finalHeight = height + 1;
|
||||||
}
|
}
|
||||||
@ -190,10 +193,6 @@ public abstract class WindowMixin {
|
|||||||
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
ConcentrationConstants.LOGGER.info("Unlocked size caching");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor != 0L) {
|
|
||||||
this.concentration$lastMonitor = monitor;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
ConcentrationConstants.LOGGER.info("Window size: {}, {}, position: {}, {}", finalWidth, finalHeight, finalX, finalY);
|
||||||
|
|
||||||
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
ConcentrationConstants.LOGGER.info("Trying to resize and reposition the window");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version=2.2.4
|
version=2.2.2
|
||||||
group=net.deechael.concentration
|
group=net.deechael.concentration
|
||||||
java_version=21
|
java_version=21
|
||||||
|
|
||||||
|
@ -48,6 +48,9 @@ public abstract class WindowMixin {
|
|||||||
@Final
|
@Final
|
||||||
private long window;
|
private long window;
|
||||||
|
|
||||||
|
@Shadow
|
||||||
|
public abstract boolean isFullscreen();
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private long concentration$lastMonitor = -1;
|
private long concentration$lastMonitor = -1;
|
||||||
|
|
||||||
@ -56,7 +59,7 @@ public abstract class WindowMixin {
|
|||||||
@Unique
|
@Unique
|
||||||
private boolean concentration$cachedPos = false;
|
private boolean concentration$cachedPos = false;
|
||||||
@Unique
|
@Unique
|
||||||
private boolean concentration$cacheSizeLock = true;
|
private boolean concentration$cacheSizeLock = false;
|
||||||
|
|
||||||
@Unique
|
@Unique
|
||||||
private int concentration$cachedX = 0;
|
private int concentration$cachedX = 0;
|
||||||
@ -154,16 +157,12 @@ public abstract class WindowMixin {
|
|||||||
finalHeight = configHeight + (configHeight == height ? 1 : 0);
|
finalHeight = configHeight + (configHeight == height ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
finalX = monitorInstance.getX();
|
finalX = monitorInstance.getX();
|
||||||
finalY = monitorInstance.getY();
|
finalY = monitorInstance.getY() - 1;
|
||||||
finalWidth = width;
|
finalWidth = width;
|
||||||
finalHeight = height + 1;
|
finalHeight = height + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monitor != 0L) {
|
|
||||||
this.concentration$lastMonitor = monitor;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.x = finalX;
|
this.x = finalX;
|
||||||
this.y = finalY;
|
this.y = finalY;
|
||||||
this.width = finalWidth;
|
this.width = finalWidth;
|
||||||
|
Loading…
Reference in New Issue
Block a user